Add Dropbear SSH support for lxc-busybox template

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>
This commit is contained in:
Purcareata Bogdan-B43198 2013-01-14 14:21:41 +00:00 committed by Stéphane Graber
parent f6d3e3e470
commit c94e60d16b

View 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
}