sshd revision 1.16
1#!/bin/sh 2# 3# $NetBSD: sshd,v 1.16 2002/04/19 23:13:44 enami Exp $ 4# 5 6# PROVIDE: sshd 7# REQUIRE: LOGIN 8 9. /etc/rc.subr 10 11name="sshd" 12rcvar=$name 13command="/usr/sbin/${name}" 14command_args='-f ${sshd_conf_dir}/${name}.conf' 15pidfile="/var/run/${name}.pid" 16load_rc_config $name 17required_files="${sshd_conf_dir}/${name}.conf" 18extra_commands="keygen reload" 19 20sshd_keygen() 21{ 22 ( 23 umask 022 24 if [ -f ${sshd_conf_dir}/ssh_host_key ]; then 25 echo "You already have an RSA host key" \ 26 "in ${sshd_conf_dir}/ssh_host_key" 27 echo "Skipping protocol version 1 RSA Key Generation" 28 else 29 /usr/bin/ssh-keygen -t rsa1 -b 1024 \ 30 -f ${sshd_conf_dir}/ssh_host_key -N '' 31 fi 32 33 if [ -f ${sshd_conf_dir}/ssh_host_dsa_key ]; then 34 echo "You already have a DSA host key" \ 35 "in ${sshd_conf_dir}/ssh_host_dsa_key" 36 echo "Skipping protocol version 2 DSA Key Generation" 37 else 38 /usr/bin/ssh-keygen -t dsa \ 39 -f ${sshd_conf_dir}/ssh_host_dsa_key -N '' 40 fi 41 42 if [ -f ${sshd_conf_dir}/ssh_host_rsa_key ]; then 43 echo "You already have a RSA host key" \ 44 "in ${sshd_conf_dir}/ssh_host_rsa_key" 45 echo "Skipping protocol version 2 RSA Key Generation" 46 else 47 /usr/bin/ssh-keygen -t rsa \ 48 -f ${sshd_conf_dir}/ssh_host_rsa_key -N '' 49 fi 50 ) 51} 52 53sshd_precmd() 54{ 55 if [ ! -f ${sshd_conf_dir}/ssh_host_key -o \ 56 ! -f ${sshd_conf_dir}/ssh_host_dsa_key -o \ 57 ! -f ${sshd_conf_dir}/ssh_host_rsa_key ]; then 58 run_rc_command keygen 59 fi 60} 61 62keygen_cmd=sshd_keygen 63start_precmd=sshd_precmd 64 65load_rc_config $name 66run_rc_command "$1" 67