--- /usr/portage/net-misc/openssh/files/sshd-r2.initd 2021-06-17 16:40:00.000000000 -0400 +++ sshd-r3.initd 2022-01-23 19:24:39.750410382 -0500 @@ -1,5 +1,5 @@ #!/sbin/openrc-run -# Copyright 1999-2021 Gentoo Authors +# Copyright 1999-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 extra_commands="checkconfig" @@ -10,6 +10,7 @@ extra_started_commands="reload" : ${SSHD_PIDFILE:=${RC_PREFIX%/}/run/${SVCNAME}.pid} : ${SSHD_BINARY:=${RC_PREFIX%/}/usr/sbin/sshd} : ${SSHD_KEYGEN_BINARY:=${RC_PREFIX%/}/usr/bin/ssh-keygen} +: ${SSHD_HOSTKEY_TYPES=""} command="${SSHD_BINARY}" pidfile="${SSHD_PIDFILE}" @@ -49,14 +50,28 @@ depend() { checkconfig() { checkpath --mode 0755 --directory "${RC_PREFIX%/}/var/empty" + # Check for sshd_config. if [ ! -e "${SSHD_CONFIG}" ] ; then eerror "You need an ${SSHD_CONFIG} file to run sshd" eerror "There is a sample file in /usr/share/doc/openssh" return 1 fi - ${SSHD_KEYGEN_BINARY} -A || return 2 + # HostKey generation. + if [ -z "${SSHD_HOSTKEY_TYPES}" ] ; then + ${SSHD_KEYGEN_BINARY} -A || return 2 + else + local hkey_type + for hkey_type in ${SSHD_HOSTKEY_TYPES}; do + local hkey_file="${SSHD_CONFDIR}/ssh_host_${hkey_type}_key" + [ -f "${hkey_file}" ] && continue + + ${SSHD_KEYGEN_BINARY} -t "${hkey_type}" \ + -f "${hkey_file}" -N '' || return 2 + done + fi + # Check sshd config file syntax "${command}" -t ${command_args} || return 3 }