sshd revision 1.13
1#!/bin/sh
2#
3# $NetBSD: sshd,v 1.13 2002/02/24 12:50:09 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"
15load_rc_config $name
16required_files="${sshd_conf_dir}/${name}.conf"
17extra_commands="keygen reload"
18
19sshd_keygen()
20{
21	(
22	umask 022
23	if [ -f ${sshd_conf_dir}/ssh_host_key ]; then
24		echo "You already have an RSA host key in ${sshd_conf_dir}/ssh_host_key"
25		echo "Skipping protocol version 1 RSA Key Generation"
26	else
27		/usr/bin/ssh-keygen -t rsa1 -b 1024 -f ${sshd_conf_dir}/ssh_host_key -N ''
28	fi
29
30	if [ -f ${sshd_conf_dir}/ssh_host_dsa_key ]; then
31		echo "You already have a DSA host key in ${sshd_conf_dir}/ssh_host_dsa_key"
32		echo "Skipping protocol version 2 DSA Key Generation"
33	else
34		/usr/bin/ssh-keygen -t dsa -f ${sshd_conf_dir}/ssh_host_dsa_key -N ''
35	fi
36
37	if [ -f ${sshd_conf_dir}/ssh_host_rsa_key ]; then
38		echo "You already have a RSA host key in ${sshd_conf_dir}/ssh_host_rsa_key"
39		echo "Skipping protocol version 2 RSA Key Generation"
40	else
41		/usr/bin/ssh-keygen -t rsa -f ${sshd_conf_dir}/ssh_host_rsa_key -N ''
42	fi
43	)
44}
45
46sshd_precmd()
47{
48	if [ ! -f ${sshd_conf_dir}/ssh_host_key -o ! -f ${sshd_conf_dir}/ssh_host_dsa_key -o \
49	     ! -f ${sshd_conf_dir}/ssh_host_rsa_key ]; then
50		$0 keygen
51	fi
52}
53
54keygen_cmd=sshd_keygen
55start_precmd=sshd_precmd
56
57load_rc_config $name
58run_rc_command "$1"
59