Date: Sun, 26 Jul 2020 10:01:27 +0000 (UTC) From: Mateusz Piotrowski <0mp@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r363553 - stable/12/libexec/rc/rc.d Message-ID: <202007261001.06QA1RFh024070@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: 0mp (doc,ports committer) Date: Sun Jul 26 10:01:27 2020 New Revision: 363553 URL: https://svnweb.freebsd.org/changeset/base/363553 Log: MFC 359973: sshd: Warn about missing ssh-keygen only when necessary The sshd service is using ssh-keygen to generate missing SSH keys. If ssh-keygen is missing, it prints the following message: > /etc/rc.d/sshd: WARNING: /usr/bin/ssh-keygen does not exist. It makes sense when the key is not generated yet and cannot be created because ssh-keygen is missing. The problem is that even if the key is present on the host, the sshd service would still warn about missing ssh-keygen (even though it does not need it). Reviewed by: emaste Approved by: emaste (src) Differential Revision: https://reviews.freebsd.org/D23911 Modified: stable/12/libexec/rc/rc.d/sshd Directory Properties: stable/12/ (props changed) Modified: stable/12/libexec/rc/rc.d/sshd ============================================================================== --- stable/12/libexec/rc/rc.d/sshd Sun Jul 26 09:58:52 2020 (r363552) +++ stable/12/libexec/rc/rc.d/sshd Sun Jul 26 10:01:27 2020 (r363553) @@ -45,18 +45,19 @@ sshd_keygen_alg() ;; esac + if [ -f "${keyfile}" ] ; then + info "$ALG host key exists." + return 0 + fi + if [ ! -x /usr/bin/ssh-keygen ] ; then warn "/usr/bin/ssh-keygen does not exist." return 1 fi - if [ -f "${keyfile}" ] ; then - info "$ALG host key exists." - else - echo "Generating $ALG host key." - /usr/bin/ssh-keygen -q -t $alg -f "$keyfile" -N "" - /usr/bin/ssh-keygen -l -f "$keyfile.pub" - fi + echo "Generating $ALG host key." + /usr/bin/ssh-keygen -q -t $alg -f "$keyfile" -N "" + /usr/bin/ssh-keygen -l -f "$keyfile.pub" } sshd_keygen()
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202007261001.06QA1RFh024070>