Bug 799928 - [RFE] Hash the hostname/port information in the known_hosts file.
[RFE] Hash the hostname/port information in the known_hosts file.
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: sssd (Show other bugs)
Unspecified Unspecified
high Severity unspecified
: rc
: ---
Assigned To: Jakub Hrozek
Kaushik Banerjee
: FutureFeature
Depends On:
  Show dependency treegraph
Reported: 2012-03-05 07:48 EST by Stephen Gallagher
Modified: 2015-02-04 17:49 EST (History)
4 users (show)

See Also:
Fixed In Version: sssd-1.9.1-1.el6
Doc Type: Enhancement
Doc Text:
Do not document
Story Points: ---
Clone Of:
Last Closed: 2013-02-21 04:20:13 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Stephen Gallagher 2012-03-05 07:48:45 EST
This bug is created as a clone of upstream ticket:

Last week I discussed the SSH known_hosts work with Honza. I thought about the stuff on the weekend. The plan is to have a global known_hosts file which gets written by sssd. This means that all users on this system have access which means reveal information to a lot of people who might not have this detailed information. So the hostnames should be stored hashed in the known_hosts file.

This way they do not reveal identifying information should the file's contents be disclosed. OpenSSH supports hashing since quite some time now.

Normally it looks like this:
|1|dTVaYG/giqH3nvoLfGECyOsiMDs=|RzAc9qu1lG+3ZtajFbaVuL02SZA= ssh-rsa ...
Here is some pseudo code for comparing it:

match_hashed_host(hostname, sourcehash) {

salt = base64_decode(sourcehash + 3)
hash = base64_decode(sourehash + strlen(salthash))

mac = sha1_hmac(hostname, salt)

if (mac == hash)
Comment 1 RHEL Product and Program Management 2012-07-10 03:06:42 EDT
This request was not resolved in time for the current release.
Red Hat invites you to ask your support representative to
propose this request, if still desired, for consideration in
the next release of Red Hat Enterprise Linux.
Comment 2 RHEL Product and Program Management 2012-07-10 22:04:46 EDT
This request was erroneously removed from consideration in Red Hat Enterprise Linux 6.4, which is currently under development.  This request will be evaluated for inclusion in Red Hat Enterprise Linux 6.4.
Comment 5 Scott Poore 2012-11-28 11:12:56 EST

Version ::


Manual Test Results ::

[root@rhel6-1 log]# ssh rhel6-1.testrelm.com
root@rhel6-1.testrelm.com's password: 
Last login: Wed Nov 28 08:45:45 2012 from

[root@rhel6-1 ~]# exit
Connection to rhel6-1.testrelm.com closed.

[root@rhel6-1 log]# ssh-keygen -H -F rhel6-1.testrelm.com -f /var/lib/sss/pubconf/known_hosts 
# Host rhel6-1.testrelm.com found: line 3 type RSA
|1|jzhcKuywO/syrzxU7BjbXAIa/kM=|RznFNMi4cWBK8/LXEdx2CqlCbSw= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAxes4L818CAuJFLTL0MOwKaL6IbG92Mx3orn0ceOvz8OlWZ3VJADiBIXC9GdDTFEzJIqP5EW/WWb7hgbjBJ0h9zmD7onxgXZj+J9m28REl1ut03KldBYcBZPGyhYs+sKRCLSp1R5BT6laoq5rYxnQuDwCa8oljhnaCpBnWu9t7le3cfXmJfWfbnCFNB5FCPc/UDL/QwuLBiq0QNoRrjOgJqygtZ7EMP3csrYB/UxkNCvycGbZ6xg49HAcci064Ek6wz5GYD7/yFQB5bqvK1cAUkLjlL5m8Osw+McU+Z/aFz/5QfDHaEJ/krlCM8HPjEYv35CG0cYt1fHQKgYARxGMqw==
# Host rhel6-1.testrelm.com found: line 4 type DSA
|1|+/qqOvsp0eYFPHyUddi+YYn5XLs=|6nvBL7cSakbCOuXZXq5smAZ70qg= ssh-dss AAAAB3NzaC1kc3MAAACBAOVwCsdmy76rq7NeRhKWzvoMFhTu4jjaDcOUi1RIJujR0MbncFaZMK2oVR4hIu/Br19ZqSFz55DurlQRpxw0RLcv3AQS4OWXu5zgMvDHK/87f0J8PlatSzNOmLNrVJZAiYe8LdhuXfd5Cz2o+LjxQ/j0YnHyg9KjJ8hY3HOFqYGVAAAAFQCTDM0w6dGWA8SGtSxVIR/CYOFyawAAAIEA04PQf1JF1HkPkfr/xRsMWPBKZvIsX5tD54Y64Pakc/A4oTKxFjTlW/Z3i62Rwx4g7VCFsjbabXJ/CvLq+zZsuqJEU8kny6Sk0SQ+ky4rbPj0zatzM8uQKFpeuY+103fKp/pn5AUUTGgCK5nf5o4lwiR4enDVG3Tp7DjOWDNkfUwAAACACpDqLiyaC+dFIaBl5tAXbEf2PieEZ6Q7wEtCAQ2IsiRGFjsXzqZYo/qZk9gWkieClVofGlSdhbyZGbBFx9Q8t/yaNFbsqB09RCzgRxlQGqgltKMEtYok9IpzegcWgkPP0VT/KGcrvTfeccLOFyCucLMpYIHs2n9QvHUEgqz2CaQ=

[root@rhel6-1 log]# knownhost="$(ssh-keygen -H -F rhel6-1.testrelm.com -f /var/lib/sss/pubconf/known_hosts |grep ssh-rsa)"

[root@rhel6-1 log]# hostname=$(hostname)

[root@rhel6-1 log]# key=$(echo ${knownhost:3:28} | base64 -d | xxd -ps)

[root@rhel6-1 log]# mac1=$(echo ${knownhost:32:28} | base64 -d | xxd -ps)

[root@rhel6-1 log]# mac2=$(echo -n $hostname | openssl dgst -sha1 -mac HMAC -macopt hexkey:$key | awk '{ print $2 }')

[root@rhel6-1 log]# [ $mac1 = $mac2 ] && echo 'Keys match'
Keys match
Comment 6 errata-xmlrpc 2013-02-21 04:20:13 EST
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Note You need to log in before you can comment on or make changes to this bug.