Recently, after some time, I have tried to login to my ssh server on the LAN, and I got this warning:
$ ssh user@local.server.hostname
Warning: Permanently added the RSA host key for IP address '192.168.1.4' to the list of known hosts.
I took a look to the following post on SO: https://stackoverflow.com/questions/9299651/warning-permanently-added-to-the-list-of-known-hosts-message-from-git
But I don't think that this is due to the ssh client that doesn't check the known_hosts
file (I guess it checks it in my case, and I am not running Windows).
Here is the known_hosts
file, and I have found that I have two lines of the same public key, but different hostnames/IPs:
$ cat ~/.ssh/known_hosts
local.server.hostname,192.168.1.3 ssh-rsa ...Here it goes the public key...
192.168.1.4 ssh-rsa ...Here it goes the same public key (as for the local.server.hostname,192.168.1.3 entry above)...
I am sure the two public keys are equal (I have checked the fingerprint of both with the command echo "here I pasted the public key" | base64 -D | md5
, which I ran for each entry of known_hosts). Otherwise I would have seen a "WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED".
Now, I have a local network with DHCP, so the server gets assigned an IP and sometimes it could get assigned a different one.
I guess this is the primary reason why I had this warning: Server IP changed (from 192.168.1.3, first line of known_hosts, to 192.168.1.4), but as the public key remained the same and the public key was already trusted by my ssh client because there was already an entry for local.server.hostname,192.168.1.3
in known_hosts
, the ssh client showed me the warning, but added the entry for 192.168.1.4
without asking me for confirmation.
Is that correct? The only thing that comes in mind is: why then the client added another entry instead of just modifying the already existing one, such as in the following way:
local.server.hostname,192.168.1.3,192.168.1.4 ssh-rsa ...public key...
Why two entries for the same public key?