summaryrefslogtreecommitdiffstats
path: root/rescue/tree/usr/sbin/startssh
diff options
context:
space:
mode:
authorFrancesc Pinyol Margalef <francesc.pinyol.m@gmail.com>2013-12-21 13:37:33 +0100
committerFrancesc Pinyol Margalef <francesc.pinyol.m@gmail.com>2013-12-21 13:37:33 +0100
commit095c6b25885ce3d22eedba8cdb98f1fd7e8708a5 (patch)
tree5bfc768996b3ddec185abeb02b602b48b14d10db /rescue/tree/usr/sbin/startssh
parentdf60191bdbddfa7c8e5bd11a2578aae6740963c0 (diff)
parentf76dc0931e47338aa9c7db257d28e5015d8a2f47 (diff)
downloaddrakx-095c6b25885ce3d22eedba8cdb98f1fd7e8708a5.tar
drakx-095c6b25885ce3d22eedba8cdb98f1fd7e8708a5.tar.gz
drakx-095c6b25885ce3d22eedba8cdb98f1fd7e8708a5.tar.bz2
drakx-095c6b25885ce3d22eedba8cdb98f1fd7e8708a5.tar.xz
drakx-095c6b25885ce3d22eedba8cdb98f1fd7e8708a5.zip
Merge branch 'master' of git://git.mageia.org/software/drakx
Diffstat (limited to 'rescue/tree/usr/sbin/startssh')
-rwxr-xr-xrescue/tree/usr/sbin/startssh27
1 files changed, 27 insertions, 0 deletions
diff --git a/rescue/tree/usr/sbin/startssh b/rescue/tree/usr/sbin/startssh
new file mode 100755
index 000000000..e14bb10e8
--- /dev/null
+++ b/rescue/tree/usr/sbin/startssh
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+# test for an up interface != lo
+if test "x"`ifconfig | cut -d ' ' -f 1 | grep -v '^$' | grep -v lo` = "x"; then
+ echo "There is no up interface, you can try to execute 'drvinst' to find drivers and 'dhcp-client' to configure your interface for DHCP." >&2
+ exit 5
+fi
+
+# generate host keys
+mkdir -p /etc/dropbear
+[[ -f /etc/dropbear/dropbear_dss_host_key ]] || dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key >/dev/null || { echo "Can't generate dsa host key" >&2 ; exit 4; }
+[[ -f /etc/dropbear/dropbear_rsa_host_key ]] || dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key >/dev/null || { echo "Can't generate rsa host key" >&2 ; exit 3; }
+
+# set a password
+passwd=`genpasswd`
+if (( $? != 0 )); then
+ reset
+ exit $?
+fi
+sed -E -i -e 's/^root:[^:]*:/root:'"${passwd//\//\\/}"':/' /etc/passwd || { echo "Can't set password" >&2 ; exit 2; }
+
+# test for /dev/pts
+grep '^devpts /dev/pts devpts ' /proc/mounts >/dev/null 2>/dev/null || mount -t devpts devpts /dev/pts
+
+echo ""
+echo -n "Starting ssh daemon... "
+dropbear -E 2>/var/log/dropbear.log && echo "OK" || { echo "Failed" ; exit 1; }