Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/etc/rc.d An sshd startup script for use with usr.bin/sshd. ...



details:   https://anonhg.NetBSD.org/src/rev/8281e36f1f08
branches:  trunk
changeset: 495572:8281e36f1f08
user:      jwise <jwise%NetBSD.org@localhost>
date:      Mon Jul 31 20:39:41 2000 +0000

description:
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.

diffstat:

 etc/rc.d/Makefile |   6 +++++-
 etc/rc.d/sshd     |  46 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 1 deletions(-)

diffs (70 lines):

diff -r 165c07b01744 -r 8281e36f1f08 etc/rc.d/Makefile
--- a/etc/rc.d/Makefile Mon Jul 31 19:57:30 2000 +0000
+++ b/etc/rc.d/Makefile Mon Jul 31 20:39:41 2000 +0000
@@ -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 @@
 FILESDIR=      /etc/rc.d
 FILESMODE=     ${BINMODE}
 
+.if defined(SSHDIST)
+FILES+=        sshd
+.endif
+
 NOPROG= noprog
 
 .include <bsd.prog.mk>
diff -r 165c07b01744 -r 8281e36f1f08 etc/rc.d/sshd
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/etc/rc.d/sshd     Mon Jul 31 20:39:41 2000 +0000
@@ -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"



Home | Main Index | Thread Index | Old Index