sshd revision 1.12
1#!/bin/sh
2#
3# $NetBSD: sshd,v 1.12 2001/04/25 23:27:37 lukem 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	(
21	umask 022
22	if [ -f /etc/ssh_host_key ]; then
23		echo "You already have an RSA host key in /etc/ssh_host_key"
24		echo "Skipping protocol version 1 RSA Key Generation"
25	else
26		/usr/bin/ssh-keygen -t rsa1 -b 1024 -f /etc/ssh_host_key -N ''
27	fi
28
29	if [ -f /etc/ssh_host_dsa_key ]; then
30		echo "You already have a DSA host key in /etc/ssh_host_dsa_key"
31		echo "Skipping protocol version 2 DSA Key Generation"
32	else
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		/usr/bin/ssh-keygen -t rsa -f /etc/ssh_host_rsa_key -N ''
41	fi
42	)
43}
44
45sshd_precmd()
46{
47	if [ ! -f /etc/ssh_host_key -o ! -f /etc/ssh_host_dsa_key -o \
48	     ! -f /etc/ssh_host_rsa_key ]; then
49		/etc/rc.d/sshd keygen
50	fi
51}
52
53keygen_cmd=sshd_keygen
54start_precmd=sshd_precmd
55
56load_rc_config $name
57run_rc_command "$1"
58