An sshd startup script for use with usr.bin/sshd. Installation is conditional

on ${SSHDIST}, as with usr.bin/ssh itself.

This script includes a `keygen' target for regenerating RSA and DSA host keys,
and invokes this if these keys are not present when sshd is started up.
This commit is contained in:
jwise 2000-07-31 20:39:41 +00:00
parent cf6fc32958
commit 5cfec6f11d
2 changed files with 51 additions and 1 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.8 2000/07/26 00:11:48 lukem Exp $
# $NetBSD: Makefile,v 1.9 2000/07/31 20:39:41 jwise Exp $
FILES= DAEMON LOGIN NETWORK SERVERS accounting amd apmd bootparams \
bootconf.sh ccd cleartmp cron dhclient dhcpd dhcrelay dmesg fsck.sh \
@ -12,6 +12,10 @@ FILES= DAEMON LOGIN NETWORK SERVERS accounting amd apmd bootparams \
FILESDIR= /etc/rc.d
FILESMODE= ${BINMODE}
.if defined(SSHDIST)
FILES+= sshd
.endif
NOPROG= noprog
.include <bsd.prog.mk>

46
etc/rc.d/sshd Executable file
View File

@ -0,0 +1,46 @@
#!/bin/sh
#
# PROVIDE: ssh
# REQUIRE: NETWORK
. /etc/rc.subr
name="sshd"
command="/usr/sbin/sshd"
required_files="/etc/sshd.conf"
extra_commands="keygen"
sshd_keygen() {
if [ -f /etc/ssh_host_key ]
then
echo "You already have an RSA host key in /etc/ssh_host_key"
echo "Skipping RSA Key Generation"
else
umask 022
/usr/bin/ssh-keygen -b 1024 -f /etc/ssh_host_key -N ''
fi
if [ -f /etc/ssh_host_dsa_key ]
then
echo "You already have a DSA host key in /etc/ssh_host_dsa_key"
echo "Skipping RSA Key Generation"
else
umask 022
/usr/bin/ssh-keygen -d -f /etc/ssh_host_dsa_key -N ''
fi
}
start_precmd() {
if [ ! -f /etc/ssh_host_key -o ! -f /etc/ssh_host_dsa_key ]
then
/etc/rc.d/sshd keygen
fi
}
keygen_cmd=sshd_keygen
start_precmd=start_precmd
load_rc_config $name
run_rc_command "$1"