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