sshd revision 1.13
11.1Slukem#!/bin/sh
21.1Slukem#
31.13Slukem# $NetBSD: sshd,v 1.13 2002/02/24 12:50:09 lukem Exp $
41.5Sjwise#
51.1Slukem
61.6Slukem# PROVIDE: sshd
71.6Slukem# REQUIRE: LOGIN
81.1Slukem
91.1Slukem. /etc/rc.subr
101.1Slukem
111.1Slukemname="sshd"
121.8Slukemrcvar=$name
131.6Slukemcommand="/usr/sbin/${name}"
141.7Slukempidfile="/var/run/${name}.pid"
151.13Slukemload_rc_config $name
161.13Slukemrequired_files="${sshd_conf_dir}/${name}.conf"
171.7Slukemextra_commands="keygen reload"
181.3Sjwise
191.6Slukemsshd_keygen()
201.6Slukem{
211.12Slukem	(
221.11Slukem	umask 022
231.13Slukem	if [ -f ${sshd_conf_dir}/ssh_host_key ]; then
241.13Slukem		echo "You already have an RSA host key in ${sshd_conf_dir}/ssh_host_key"
251.9Sitojun		echo "Skipping protocol version 1 RSA Key Generation"
261.3Sjwise	else
271.13Slukem		/usr/bin/ssh-keygen -t rsa1 -b 1024 -f ${sshd_conf_dir}/ssh_host_key -N ''
281.3Sjwise	fi
291.3Sjwise
301.13Slukem	if [ -f ${sshd_conf_dir}/ssh_host_dsa_key ]; then
311.13Slukem		echo "You already have a DSA host key in ${sshd_conf_dir}/ssh_host_dsa_key"
321.9Sitojun		echo "Skipping protocol version 2 DSA Key Generation"
331.3Sjwise	else
341.13Slukem		/usr/bin/ssh-keygen -t dsa -f ${sshd_conf_dir}/ssh_host_dsa_key -N ''
351.9Sitojun	fi
361.9Sitojun
371.13Slukem	if [ -f ${sshd_conf_dir}/ssh_host_rsa_key ]; then
381.13Slukem		echo "You already have a RSA host key in ${sshd_conf_dir}/ssh_host_rsa_key"
391.9Sitojun		echo "Skipping protocol version 2 RSA Key Generation"
401.9Sitojun	else
411.13Slukem		/usr/bin/ssh-keygen -t rsa -f ${sshd_conf_dir}/ssh_host_rsa_key -N ''
421.3Sjwise	fi
431.12Slukem	)
441.3Sjwise}
451.3Sjwise
461.6Slukemsshd_precmd()
471.6Slukem{
481.13Slukem	if [ ! -f ${sshd_conf_dir}/ssh_host_key -o ! -f ${sshd_conf_dir}/ssh_host_dsa_key -o \
491.13Slukem	     ! -f ${sshd_conf_dir}/ssh_host_rsa_key ]; then
501.13Slukem		$0 keygen
511.3Sjwise	fi
521.3Sjwise}
531.3Sjwise
541.3Sjwisekeygen_cmd=sshd_keygen
551.5Sjwisestart_precmd=sshd_precmd
561.3Sjwise
571.3Sjwiseload_rc_config $name
581.3Sjwiserun_rc_command "$1"
59