Bug 208254 - rc.d/sshd failes to generate all referenced ssh host keys.
Summary: rc.d/sshd failes to generate all referenced ssh host keys.
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: conf (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Many People
Assignee: Dag-Erling Smørgrav
URL:
Keywords:
: 207366 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-03-24 03:18 UTC by Peter Wemm
Modified: 2016-08-11 10:44 UTC (History)
5 users (show)

See Also:
des: mfc-stable11+


Attachments
Check whether each key file exists before adding it (1.79 KB, patch)
2016-03-25 12:26 UTC, Dag-Erling Smørgrav
no flags Details | Diff
Check whether each key file exists before adding it (1.82 KB, patch)
2016-08-08 10:24 UTC, Dag-Erling Smørgrav
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Wemm freebsd_committer freebsd_triage 2016-03-24 03:18:39 UTC
By default, sshd expects /etc/ssh/ssh_host_dsa_key to exist.  /etc/rc.d/sshd no longer generates it by default.  This leads to a lot of console noise for every.. single.. incoming.. connection.


$ grep dsa etc/rc.d/sshd 
...
: ${sshd_dsa_enable:="no"}
...

(Test the default built-in configuration)
# sshd -t -f /dev/null
Could not load host key: /etc/ssh/ssh_host_dsa_key

(Test the default freebsd-11 configuration)
# sshd -t -f /etc/ssh/sshd_config 
Could not load host key: /etc/ssh/ssh_host_dsa_key

The logical fix is to re-enable the host key generation until sshd is smarter about this.  It can't spam this on the console for every connection.
Comment 1 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2016-03-25 12:26:13 UTC
Created attachment 168616 [details]
Check whether each key file exists before adding it

Please test the attached patch.
Comment 2 Peter Wemm freebsd_committer freebsd_triage 2016-03-27 08:11:21 UTC
This appears to work as I would expect, at least noise-wise.

FWIW, the approach in general feels a little odd to me.  eg: with no ssh_host_dsa_key family, a "sshd -T -f /etc/ssh/sshd_config" still shows "ssh-dss" for pub keys, and you can still log in with ssh-dsa keys.  It feels a little odd to disable dsa for host keys, but leave it enabled for authentication.

peter@overcee[ 1:05AM]~/.ssh-1017> ssh -v -i id_dsa tiny.nyi
...
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:OrntpV5eSy6jIYRMZ1e84yjuQHd0DJAhMaOp8Vz5obQ
...
debug1: Offering DSA public key: id_dsa
debug1: Server accepts key: pkalg ssh-dss blen 433
Enter passphrase for key 'id_dsa': 
debug1: Authentication succeeded (publickey).
Authenticated to tiny.nyi ([2610:1c1:1:610b::16:1]:22).
...
peter@tiny.nyi:~ % ls -l /etc/ssh/ssh_host_dsa*
ls: No match.

Looking at rc.d/sshd:

: ${sshd_rsa1_enable:="no"}
: ${sshd_rsa_enable:="yes"}
: ${sshd_dsa_enable:="no"}
: ${sshd_ecdsa_enable:="yes"}
: ${sshd_ed25519_enable:="yes"}

It kind of implies that dsa is turned off.  It seems surprising to me that DSA keys are still quite fine for authentication.  Is this really intended?
Comment 3 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2016-03-29 06:58:57 UTC
(In reply to Peter Wemm from comment #2)
> FWIW, the approach in general feels a little odd to me.  eg: with no
> ssh_host_dsa_key family, a "sshd -T -f /etc/ssh/sshd_config" still shows
> "ssh-dss" for pub keys, and you can still log in with ssh-dsa keys.  It feels
a
> little odd to disable dsa for host keys, but leave it enabled for
> authentication.
 
Those are two completely separate things in the protocol and
configuration (HostKeyAlgorithms vs PubkeyAcceptedKeyTypes).
 
> It kind of implies that dsa is turned off.  It seems surprising to me
> that DSA keys are still quite fine for authentication.  Is this really
> intended?
 
Yes.
Comment 4 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2016-04-04 09:43:41 UTC
*** Bug 207366 has been marked as a duplicate of this bug. ***
Comment 5 commit-hook freebsd_committer freebsd_triage 2016-08-05 15:33:37 UTC
A commit references this bug:

Author: des
Date: Fri Aug  5 15:32:36 UTC 2016
New revision: 303770
URL: https://svnweb.freebsd.org/changeset/base/303770

Log:
  MFH (r303716, r303719): drop SSH1 support, disable DSA by default

  PR:		208254
  Approved by:	re (gjb)
  Relnotes:	yes

Changes:
_U  stable/11/
  stable/11/crypto/openssh/FREEBSD-upgrade
  stable/11/crypto/openssh/config.h
  stable/11/crypto/openssh/configure.ac
  stable/11/crypto/openssh/myproposal.h
  stable/11/crypto/openssh/servconf.c
  stable/11/crypto/openssh/ssh_config.5
  stable/11/crypto/openssh/sshd_config.5
  stable/11/etc/rc.d/sshd
Comment 6 Peter Wemm freebsd_committer freebsd_triage 2016-08-05 21:51:34 UTC
The console spam has been MFC'ed to 11 now too!

Please commit the fix!
Comment 7 Glen Barber freebsd_committer freebsd_triage 2016-08-05 21:58:03 UTC
DES, could you please commit the patch included above?
Comment 8 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2016-08-06 13:07:17 UTC
(In reply to Glen Barber from comment #7)
> DES, could you please commit the patch included above?

Sorry, I need to investigate.  The actual bug is that it shouldn't try to load the DSA key at all.  I thought I had reverted all DSA-related changes, but apparently I missed one.  Looks like lines 217-218 of servconf.c need to be removed.
Comment 9 Peter Wemm freebsd_committer freebsd_triage 2016-08-06 19:49:31 UTC
I'm starting this month's cluster refresh with the rc.d change backed out, so that sshd_dsa_enable:="yes".  This generates a massive amount of error message spam for us due to the unexpected output from sshd config file test mode as in the original report from 4 months ago.
Comment 10 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2016-08-08 10:24:00 UTC
Created attachment 173396 [details]
Check whether each key file exists before adding it

Updated patch
Comment 11 commit-hook freebsd_committer freebsd_triage 2016-08-08 10:46:38 UTC
A commit references this bug:

Author: des
Date: Mon Aug  8 10:46:18 UTC 2016
New revision: 303832
URL: https://svnweb.freebsd.org/changeset/base/303832

Log:
  Try to check whether each key file exists before adding it, and bail out
  if we didn't find any of them.  This reduces log spam about key files for
  deprecated algorithms, which we look for but don't generate.

  PR:		208254
  MFC after:	3 days

Changes:
  head/crypto/openssh/servconf.c
Comment 12 Bryan Drewery freebsd_committer freebsd_triage 2016-08-10 19:35:58 UTC
There is also https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=202153 which avoids
modifying the SSH source.  We could still generate the key but not enable the
algorithm.  I don't see much harm in generating the key.
Comment 13 commit-hook freebsd_committer freebsd_triage 2016-08-11 08:29:34 UTC
A commit references this bug:

Author: des
Date: Thu Aug 11 08:29:16 UTC 2016
New revision: 303952
URL: https://svnweb.freebsd.org/changeset/base/303952

Log:
  MFH (r303832): check whether each key file exists before adding it

  PR:		208254
  Approved by:	re (kib)

Changes:
_U  stable/11/
  stable/11/crypto/openssh/servconf.c