$rootfs/etc \
$rootfs/etc/init.d \
$rootfs/bin \
+$rootfs/usr/bin \
$rootfs/sbin \
+$rootfs/usr/sbin \
$rootfs/proc \
$rootfs/mnt \
$rootfs/tmp \
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
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
}