From c94e60d16bfcda262ac907bf9667abdc46c07fa8 Mon Sep 17 00:00:00 2001 From: Purcareata Bogdan-B43198 Date: Mon, 14 Jan 2013 14:21:41 +0000 Subject: [PATCH] Add Dropbear SSH support for lxc-busybox template MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dropbear implements lightweight SSH2 server and client functionality and is likely to be included in embedded Linux distros. Signed-off-by: Purcareata Bogdan Acked-by: Stéphane Graber --- templates/lxc-busybox.in | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/templates/lxc-busybox.in b/templates/lxc-busybox.in index f2751d8fa..439657f87 100644 --- a/templates/lxc-busybox.in +++ b/templates/lxc-busybox.in @@ -33,7 +33,9 @@ $rootfs/root \ $rootfs/etc \ $rootfs/etc/init.d \ $rootfs/bin \ +$rootfs/usr/bin \ $rootfs/sbin \ +$rootfs/usr/sbin \ $rootfs/proc \ $rootfs/mnt \ $rootfs/tmp \ @@ -63,6 +65,8 @@ $rootfs/usr/lib64" chmod 600 ram0 || res=1 mknod null c 1 3 || res=1 chmod 666 null || res=1 + mknod urandom c 1 9 || res=1 + chmod 666 urandom || res=1 popd > /dev/null @@ -188,6 +192,35 @@ configure_busybox() echo "setting root passwd to root" echo "root:root" | chroot $rootfs chpasswd + + # add ssh functionality if dropbear package available on host + type dropbear >/dev/null + if [ $? -eq 0 ]; then + # copy dropbear binary + cp $(which dropbear) $rootfs/usr/sbin + if [ $? -ne 0 ]; then + echo "Failed to copy dropbear in the rootfs" + return 1 + fi + + # make symlinks to various ssh utilities + utils="\ + $rootfs/usr/bin/dbclient \ + $rootfs/usr/bin/scp \ + $rootfs/usr/bin/ssh \ + $rootfs/usr/sbin/dropbearkey \ + $rootfs/usr/sbin/dropbearconvert \ + " + echo $utils | xargs -n1 ln -s /usr/sbin/dropbear + + # add necessary config files + mkdir $rootfs/etc/dropbear + dropbearkey -t rsa -f $rootfs/etc/dropbear/dropbear_rsa_host_key &> /dev/null + dropbearkey -t dss -f $rootfs/etc/dropbear/dropbear_dss_host_key &> /dev/null + + echo "'dropbear' ssh utility installed" + fi + return 0 }