Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Apr 2020 14:07:34 +0000 (UTC)
From:      Mateusz Piotrowski <0mp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r359973 - head/libexec/rc/rc.d
Message-ID:  <202004151407.03FE7YKa057896@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: 0mp (doc,ports committer)
Date: Wed Apr 15 14:07:33 2020
New Revision: 359973
URL: https://svnweb.freebsd.org/changeset/base/359973

Log:
  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)
  MFC after:	2 weeks
  Differential Revision:	https://reviews.freebsd.org/D23911

Modified:
  head/libexec/rc/rc.d/sshd

Modified: head/libexec/rc/rc.d/sshd
==============================================================================
--- head/libexec/rc/rc.d/sshd	Wed Apr 15 13:59:51 2020	(r359972)
+++ head/libexec/rc/rc.d/sshd	Wed Apr 15 14:07:33 2020	(r359973)
@@ -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?202004151407.03FE7YKa057896>