1#!/bin/sh 2# 3# $NetBSD: sshd,v 1.20 2004/08/13 18:08:03 mycroft Exp $ 4# 5 6# PROVIDE: sshd 7# REQUIRE: LOGIN 8 9$_rc_subr_loaded . /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 ${ssh_keygen_flags} \ 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 ${ssh_keygen_flags} \ 37 -f /etc/ssh/ssh_host_dsa_key -N '' 38 fi 39 40 if [ -f /etc/ssh/ssh_host_rsa_key ]; then 41 echo "You already have a RSA host key" \ 42 "in /etc/ssh/ssh_host_rsa_key" 43 echo "Skipping protocol version 2 RSA Key Generation" 44 else 45 /usr/bin/ssh-keygen -t rsa ${ssh_keygen_flags} \ 46 -f /etc/ssh/ssh_host_rsa_key -N '' 47 fi 48 ) 49} 50 51sshd_precmd() 52{ 53 if [ ! -f /etc/ssh/ssh_host_key -o \ 54 ! -f /etc/ssh/ssh_host_dsa_key -o \ 55 ! -f /etc/ssh/ssh_host_rsa_key ]; then 56 run_rc_command keygen 57 fi 58} 59 60keygen_cmd=sshd_keygen 61start_precmd=sshd_precmd 62 63load_rc_config $name 64run_rc_command "$1" 65