View | Details | Raw Unified | Return to bug 73909
Collapse All | Expand All

(-)sshd (-15 / +26 lines)
Lines 15-23 Link Here
15
start_precmd="sshd_precmd"
15
start_precmd="sshd_precmd"
16
pidfile="/var/run/${name}.pid"
16
pidfile="/var/run/${name}.pid"
17
extra_commands="keygen reload"
17
extra_commands="keygen reload"
18
timeout=300
18
timeout=300
19
19
20
get_prefix() {
21
	PREFIX=${sshd_program%%/sbin/sshd}
22
	if [ "$PREFIX" != "/usr" ] ; then
23
		ETCDIR="$PREFIX/etc"
24
	else
25
		ETCDIR="/etc"
26
	fi
27
}
28
20
user_reseed()
29
user_reseed()
21
{
30
{
22
	(
31
	(
Lines 42-88 Link Here
42
50
43
sshd_keygen()
51
sshd_keygen()
44
{
52
{
53
	get_prefix
45
	(
54
	(
46
	umask 022
55
	umask 022
47
56
48
	# Can't do anything if ssh is not installed
57
	# Can't do anything if ssh is not installed
49
	[ -x /usr/bin/ssh-keygen ] || {
58
	[ -x ${PREFIX}/bin/ssh-keygen ] || {
50
		warn "/usr/bin/ssh-keygen does not exist."
59
		warn "${PREFIX}/bin/ssh-keygen does not exist."
51
		return 1
60
		return 1
52
	}
61
	}
53
62
54
	if [ -f /etc/ssh/ssh_host_key ]; then
63
	if [ -f ${ETCDIR}/ssh/ssh_host_key ]; then
55
		echo "You already have an RSA host key" \
64
		echo "You already have an RSA host key" \
56
		    "in /etc/ssh/ssh_host_key"
65
		    "in ${ETCDIR}/ssh/ssh_host_key"
57
		echo "Skipping protocol version 1 RSA Key Generation"
66
		echo "Skipping protocol version 1 RSA Key Generation"
58
	else
67
	else
59
		/usr/bin/ssh-keygen -t rsa1 -b 1024 \
68
		${PREFIX}/bin/ssh-keygen -t rsa1 -b 1024 \
60
		    -f /etc/ssh/ssh_host_key -N ''
69
		    -f ${ETCDIR}/ssh/ssh_host_key -N ''
61
	fi
70
	fi
62
71
63
	if [ -f /etc/ssh/ssh_host_dsa_key ]; then
72
	if [ -f ${ETCDIR}/ssh/ssh_host_dsa_key ]; then
64
		echo "You already have a DSA host key" \
73
		echo "You already have a DSA host key" \
65
		    "in /etc/ssh/ssh_host_dsa_key"
74
		    "in ${ETCDIR}/ssh/ssh_host_dsa_key"
66
		echo "Skipping protocol version 2 DSA Key Generation"
75
		echo "Skipping protocol version 2 DSA Key Generation"
67
	else
76
	else
68
		/usr/bin/ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N ''
77
		${PREFIX}/bin/ssh-keygen -t dsa -f ${ETCDIR}/ssh/ssh_host_dsa_key -N ''
69
	fi
78
	fi
70
79
71
	if [ -f /etc/ssh/ssh_host_rsa_key ]; then
80
	if [ -f ${ETCDIR}/ssh/ssh_host_rsa_key ]; then
72
		echo "You already have a RSA host key" \
81
		echo "You already have a RSA host key" \
73
		    "in /etc/ssh/ssh_host_rsa_key"
82
		    "in ${ETCDIR}/ssh/ssh_host_rsa_key"
74
		echo "Skipping protocol version 2 RSA Key Generation"
83
		echo "Skipping protocol version 2 RSA Key Generation"
75
	else
84
	else
76
		/usr/bin/ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ''
85
		${PREFIX}/bin/ssh-keygen -t rsa -f ${ETCDIR}/ssh/ssh_host_rsa_key -N ''
77
	fi
86
	fi
78
	)
87
	)
79
}
88
}
80
89
81
sshd_precmd()
90
sshd_precmd()
82
{
91
{
83
	if [ ! -f /etc/ssh/ssh_host_key -o \
92
	get_prefix
84
	    ! -f /etc/ssh/ssh_host_dsa_key -o \
93
	if [ ! -f ${ETCDIR}/ssh/ssh_host_key -o \
85
	    ! -f /etc/ssh/ssh_host_rsa_key ]; then
94
	    ! -f ${ETCDIR}/ssh/ssh_host_dsa_key -o \
95
	    ! -f ${ETCDIR}/ssh/ssh_host_rsa_key ]; then
86
		user_reseed
96
		user_reseed
87
		run_rc_command keygen
97
		run_rc_command keygen
88
	fi
98
	fi

Return to bug 73909