1

I'd like to change the default setting for HostKeyAlgorithms for all SSH connections to prefer ssh-ed25519 over ecdsa-sha2-nistp256. But I currently have ecdsa-sha2-nistp256 host keys for many hosts in my known_hosts file (about 70). When I connect to such a host with the new setting, I get the same message as if someone replaced the host key on that host:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ED25519 key sent by the remote host is
SHA256:rqhdlN+Qe/GJeWoj3pyhLLSnzSCz68ZA7ds+mG4iZ7o.
Please contact your system administrator.
Add correct host key in [...]/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in [...]/.ssh/known_hosts:52
ED25519 host key for [...] has changed and you have requested strict checking.
Host key verification failed.

Now I would rather not have to remove all those host from my known_hosts file and accept the "new" ED25519 keys on the next connection. Rather I'd like to have a way to continue with the existing contents of that file. Is there any way to do this? E.g. by falling back to the known host key even when is not using the preferred algorithm. Or is there an automated way to replace all those entries?

Feuermurmel
  • 151
  • 1
  • 8

1 Answers1

1

I was answering similar question on Unix so to make it short, in OpenSSH 6.8+ there is option UpdateHostKeys, which says to your client that it should pick up all the host keys offered by server.

This should resolve your problems.

Jakuje
  • 9,145
  • 2
  • 40
  • 44
  • Hmm. That solution requires OpenSSH 6.8, which has not yet managed to get into Debian stable. ._. Fair enough. Its security. It should not be easy as otherwise people would use it. – Feuermurmel Feb 20 '17 at 16:53