sshd revision 124616
1#!/bin/sh 2# 3# $NetBSD: sshd,v 1.18 2002/04/29 08:23:34 lukem Exp $ 4# $FreeBSD: head/etc/rc.d/sshd 124616 2004-01-17 10:16:38Z mtm $ 5# 6 7# PROVIDE: sshd 8# REQUIRE: LOGIN 9# KEYWORD: FreeBSD 10 11. /etc/rc.subr 12 13name="sshd" 14rcvar=`set_rcvar` 15keygen_cmd="sshd_keygen" 16start_precmd="sshd_precmd" 17pidfile="/var/run/${name}.pid" 18extra_commands="keygen reload" 19case ${OSTYPE} in 20NetBSD) 21 command="/usr/sbin/${name}" 22 required_files="/etc/ssh/sshd_config" 23 ;; 24esac 25 26sshd_keygen() 27{ 28 ( 29 umask 022 30 31 # Can't do anything if ssh is not installed 32 [ -x /usr/bin/ssh-keygen ] || { 33 warn "/usr/bin/ssh-keygen does not exist." 34 return 1 35 } 36 37 if [ -f /etc/ssh/ssh_host_key ]; then 38 echo "You already have an RSA host key" \ 39 "in /etc/ssh/ssh_host_key" 40 echo "Skipping protocol version 1 RSA Key Generation" 41 else 42 /usr/bin/ssh-keygen -t rsa1 -b 1024 \ 43 -f /etc/ssh/ssh_host_key -N '' 44 fi 45 46 if [ -f /etc/ssh/ssh_host_dsa_key ]; then 47 echo "You already have a DSA host key" \ 48 "in /etc/ssh/ssh_host_dsa_key" 49 echo "Skipping protocol version 2 DSA Key Generation" 50 else 51 /usr/bin/ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N '' 52 fi 53 54 if [ -f /etc/ssh/ssh_host_rsa_key ]; then 55 echo "You already have a RSA host key" \ 56 "in /etc/ssh/ssh_host_rsa_key" 57 echo "Skipping protocol version 2 RSA Key Generation" 58 else 59 /usr/bin/ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' 60 fi 61 ) 62} 63 64sshd_precmd() 65{ 66 if [ ! -f /etc/ssh/ssh_host_key -o \ 67 ! -f /etc/ssh/ssh_host_dsa_key -o \ 68 ! -f /etc/ssh/ssh_host_rsa_key ]; then 69 run_rc_command keygen 70 fi 71} 72 73load_rc_config $name 74run_rc_command "$1" 75