sshd revision 1.9
1#!/bin/sh
2#
3# $NetBSD: sshd,v 1.9 2001/03/26 22:21:26 itojun Exp $
4#
5
6# PROVIDE: sshd
7# REQUIRE: LOGIN
8
9. /etc/rc.subr
10
11name="sshd"
12rcvar=$name
13command="/usr/sbin/${name}"
14pidfile="/var/run/${name}.pid"
15required_files="/etc/${name}.conf"
16extra_commands="keygen reload"
17
18sshd_keygen()
19{
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 protocol version 1 RSA Key Generation"
23	else
24		umask 022
25		/usr/bin/ssh-keygen -t rsa1 -b 1024 -f /etc/ssh_host_key -N ''
26	fi
27
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 protocol version 2 DSA Key Generation"
31	else
32		umask 022
33		/usr/bin/ssh-keygen -t dsa -f /etc/ssh_host_dsa_key -N ''
34	fi
35
36	if [ -f /etc/ssh_host_rsa_key ]; then
37		echo "You already have a RSA host key in /etc/ssh_host_rsa_key"
38		echo "Skipping protocol version 2 RSA Key Generation"
39	else
40		umask 022
41		/usr/bin/ssh-keygen -t rsa -f /etc/ssh_host_rsa_key -N ''
42	fi
43}
44
45sshd_precmd()
46{
47	if [ ! -f /etc/ssh_host_key -o ! -f /etc/ssh_host_dsa_key ]; then
48		/etc/rc.d/sshd keygen
49	fi
50}
51
52keygen_cmd=sshd_keygen
53start_precmd=sshd_precmd
54
55load_rc_config $name
56run_rc_command "$1"
57