Deleted Added
full compact
sshd (78345) sshd (98184)
1#!/bin/sh
2#
1#!/bin/sh
2#
3# $NetBSD: sshd,v 1.7 2000/08/10 22:49:43 lukem Exp $
3# $NetBSD: sshd,v 1.18 2002/04/29 08:23:34 lukem Exp $
4# $FreeBSD: head/etc/rc.d/sshd 98184 2002-06-13 22:14:37Z gordon $
4#
5
6# PROVIDE: sshd
7# REQUIRE: LOGIN
5#
6
7# PROVIDE: sshd
8# REQUIRE: LOGIN
9# KEYWORD: FreeBSD NetBSD
8
9. /etc/rc.subr
10
11name="sshd"
10
11. /etc/rc.subr
12
13name="sshd"
12rcvar=$name
14rcvar=`set_rcvar`
13command="/usr/sbin/${name}"
15command="/usr/sbin/${name}"
16keygen_cmd="sshd_keygen"
17start_precmd="sshd_precmd"
14pidfile="/var/run/${name}.pid"
18pidfile="/var/run/${name}.pid"
15required_files="/etc/${name}.conf"
19required_files="/etc/ssh/sshd_config"
16extra_commands="keygen reload"
17
18sshd_keygen()
19{
20extra_commands="keygen reload"
21
22sshd_keygen()
23{
20 if [ -f /etc/ssh_host_key ]; then
21 echo "You already have an RSA host key in /etc/ssh_host_key"
22 echo "Skipping RSA Key Generation"
24 (
25 umask 022
26
27 # Can't do anything if ssh is not installed
28 [ -x /usr/bin/ssh-keygen ] || {
29 warn "/usr/bin/ssh-keygen does not exist."
30 return 1
31 }
32
33 if [ -f /etc/ssh/ssh_host_key ]; then
34 echo "You already have an RSA host key" \
35 "in /etc/ssh/ssh_host_key"
36 echo "Skipping protocol version 1 RSA Key Generation"
23 else
37 else
24 umask 022
25 /usr/bin/ssh-keygen -b 1024 -f /etc/ssh_host_key -N ''
38 /usr/bin/ssh-keygen -t rsa1 -b 1024 \
39 -f /etc/ssh/ssh_host_key -N ''
26 fi
27
40 fi
41
28 if [ -f /etc/ssh_host_dsa_key ]; then
29 echo "You already have a DSA host key in /etc/ssh_host_dsa_key"
30 echo "Skipping DSA Key Generation"
42 if [ -f /etc/ssh/ssh_host_dsa_key ]; then
43 echo "You already have a DSA host key" \
44 "in /etc/ssh/ssh_host_dsa_key"
45 echo "Skipping protocol version 2 DSA Key Generation"
31 else
46 else
32 umask 022
33 /usr/bin/ssh-keygen -d -f /etc/ssh_host_dsa_key -N ''
47 /usr/bin/ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N ''
34 fi
48 fi
49
50 if [ -f /etc/ssh/ssh_host_rsa_key ]; then
51 echo "You already have a RSA host key" \
52 "in /etc/ssh/ssh_host_rsa_key"
53 echo "Skipping protocol version 2 RSA Key Generation"
54 else
55 /usr/bin/ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ''
56 fi
57 )
35}
36
37sshd_precmd()
38{
58}
59
60sshd_precmd()
61{
39 if [ ! -f /etc/ssh_host_key -o ! -f /etc/ssh_host_dsa_key ]; then
40 /etc/rc.d/sshd keygen
62 if [ ! -f /etc/ssh/ssh_host_key -o \
63 ! -f /etc/ssh/ssh_host_dsa_key -o \
64 ! -f /etc/ssh/ssh_host_rsa_key ]; then
65 run_rc_command keygen
41 fi
42}
43
66 fi
67}
68
44keygen_cmd=sshd_keygen
45start_precmd=sshd_precmd
46
47load_rc_config $name
48run_rc_command "$1"
69load_rc_config $name
70run_rc_command "$1"