sshd revision 1.24
1#!/bin/sh 2# 3# $NetBSD: sshd,v 1.24 2017/10/07 21:41:51 sevan 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 keygen="/usr/bin/ssh-keygen" 22 umask 022 23 while read type bits filename version name; do 24 f="/etc/ssh/$filename" 25 if [ -f "$f" ]; then 26 echo "You already have an $name host key in $f" 27 echo "Skipping protocol version $version $name" \ 28 "Key Generation" 29 else 30 case "${bits}" in 31 -1) bitarg=;; 32 0) bitarg="${ssh_keygen_flags}";; 33 *) bitarg="-b ${bits}";; 34 esac 35 "${keygen}" -t "${type}" ${bitarg} -f "${f}" -N '' 36 fi 37 done << _EOF 38dsa 1024 ssh_host_dsa_key 2 DSA 39ecdsa 521 ssh_host_ecdsa_key 1 ECDSA 40ed25519 -1 ssh_host_ed25519_key 1 ED25519 41rsa 0 ssh_host_rsa_key 2 RSA 42_EOF 43) 44} 45 46sshd_precmd() 47{ 48 if [ ! -f /etc/ssh/ssh_host_dsa_key -o \ 49 ! -f /etc/ssh/ssh_host_ecdsa_key -o \ 50 ! -f /etc/ssh/ssh_host_ed25519_key -o \ 51 ! -f /etc/ssh/ssh_host_rsa_key ]; then 52 run_rc_command keygen 53 fi 54} 55 56keygen_cmd=sshd_keygen 57start_precmd=sshd_precmd 58 59load_rc_config $name 60run_rc_command "$1" 61