NetBSD/etc/rc.d/sshd

54 lines
942 B
Bash
Executable File

#!/bin/sh
#
# $NetBSD: sshd,v 1.30 2019/10/23 14:45:38 christos Exp $
#
# PROVIDE: sshd
# REQUIRE: LOGIN
$_rc_subr_loaded . /etc/rc.subr
name="sshd"
rcvar=$name
command="/usr/sbin/${name}"
pidfile="/var/run/${name}.pid"
required_files="/etc/ssh/sshd_config"
extra_commands="keygen reload"
sshd_keygen()
{
(
keygen="/usr/bin/ssh-keygen"
umask 022
while read type bits filename; do
f="/etc/ssh/$filename"
if [ -f "$f" ]; then
continue
fi
case "${bits}" in
-1) bitarg=;;
0) bitarg="${ssh_keygen_flags}";;
*) bitarg="-b ${bits}";;
esac
"${keygen}" -t "${type}" ${bitarg} -f "${f}" -N '' -q && \
printf "ssh-keygen: " && "${keygen}" -f "${f}" -l
done << _EOF
dsa 1024 ssh_host_dsa_key
ecdsa 521 ssh_host_ecdsa_key
ed25519 -1 ssh_host_ed25519_key
rsa 0 ssh_host_rsa_key
_EOF
)
}
sshd_precmd()
{
run_rc_command keygen
}
keygen_cmd=sshd_keygen
start_precmd=sshd_precmd
load_rc_config $name
run_rc_command "$1"