summaryrefslogtreecommitdiffstats
path: root/rescue/startssh
blob: 19795aaa152d86a31f1b4682d7b723728d1ece33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash

passwd=`genpasswd`

if (( $? != 0 )); then
	reset
	exit $?
fi

# change passwd file
sed -E -i -e 's/^root:[^:]*:/root:'"$passwd"':/' /etc/passwd

# dropbear must have /dev/pts mounted
grep '^devpts /dev/pts devpts ' /proc/mounts >/dev/null 2>/dev/null || mount -t devpts devpts /dev/pts

# 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
[[ -f /etc/dropbear/dropbear_rsa_host_key ]] || dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key >/dev/null

echo ""
echo -n "Starting ssh daemon... "
dropbear -E 2>/var/log/dropbear.log && echo "OK"