Fedora: Creating Debian chroot with ssh server

I use Fedora on the Desktop but I need to do some development on Debian. chroots gives you no performance overhead, while virtual machines gives you CPU and memory insulation. Also the chroot is only a directory on my development tree.

I'm using Fedora 17 on my workstation and Debian 7 inside the chroot. The debootstrap command will save the files on the directory debian7-chroot/ under the current directory.

1 - Install debootstrap and dpkg on Fedora:
Fedora # yum install debootstrap dpkg

2 - Create the basic Debian:
Fedora # debootstrap wheezy debian7-chroot/ http://ftp.fr.debian.org/debian

3 - Enter your new Debian:
Fedora # chroot /path/to/destdir

4 - Install additional useful packages:
debian-chroot: # apt-get install locales less vim openssh-server sudo aptitude

5 - Configure openssh server to start server on port 2222:
debian-chroot: # vi /etc/ssh/sshd_config

Chage:
Port 22

To:
Port 2222

6 - Change root password
debian-chroot: # passwd

7 - Return to your desktop distro:
debian-chroot: # exit

8 - Create start and stop script for your chrooted Debian:
Fedora # cat start.sh

#!/bin/bash
umount debian7-chroot/tmp debian7-chroot/proc debian7-chroot/sys debian7-chroot/dev/pts debian7-chroot/dev
umount debian7-chroot/tmp debian7-chroot/proc debian7-chroot/sys debian7-chroot/dev/pts debian7-chroot/dev

mount /tmp debian7-chroot/tmp -o bind
mount proc debian7-chroot/proc -t proc -o nosuid,noexec,nodev
mount sysfs debian7-chroot/sys -t sysfs -o nosuid,noexec,nodev
mount devtmpfs debian7-chroot/dev -t devtmpfs -o mode=0755,nosuid
mount devpts debian7-chroot/dev/pts -t devpts -o gid=5,mode=620

chroot debian7-chroot /etc/init.d/ssh stop
chroot debian7-chroot /etc/init.d/ssh start

Fedora # cat stop.sh

#!/bin/bash
chroot debian7-chroot /etc/init.d/ssh stop

umount debian7-chroot/tmp debian7-chroot/proc debian7-chroot/sys debian7-chroot/dev/pts debian7-chroot/dev
umount debian7-chroot/tmp debian7-chroot/proc debian7-chroot/sys debian7-chroot/dev/pts debian7-chroot/dev

9 - Start the ssh server inside the Debian chroot:
Fedora # ./start.sh

10 - Connect over ssh to Debian chroot:
Fedora # ssh root@localhost -p 2200



Comments

Popular posts from this blog

Toshiba R830 and 16GB of RAM

Five steps to create Fedora chroot jail using yum

GitHub Social Coding