]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Add Dropbear SSH support for lxc-busybox template
authorPurcareata Bogdan-B43198 <B43198@freescale.com>
Mon, 14 Jan 2013 14:21:41 +0000 (14:21 +0000)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 15 Jan 2013 17:18:36 +0000 (12:18 -0500)
Dropbear implements lightweight SSH2 server and client functionality and
is likely to be included in embedded Linux distros.

Signed-off-by: Purcareata Bogdan <B43198@freescale.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
templates/lxc-busybox.in

index f2751d8faf4f6c884a4856675200c6ccc02bd1d8..439657f87bce242ad3bf18cdad06f4dbfd040f44 100644 (file)
@@ -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
 }