0

I created new host keys on serverA, updated sshd_config accordingly (adding the line below) and restarted ssh:

cd /etc/ssh sudo ssh-keygen -f 2024_ssh_host_ed25519_key -t ed25519 -N '' sudo vi /etc/ssh/sshd_config # added line: HostKey /etc/ssh/2024_ssh_host_ed25519_key sudo service ssh restart 

When I connect to serverA (ssh -v -o UpdateHostKeys=yes serverA) afterwards, known_hosts on the client is not updated. The output of the ssh command contains this:

debug1: Host '[serverA.domain.internal]:22' is known and matches the ED25519 host key. # ... debug1: client_input_hostkeys: searching /Users/snafu/.ssh/known_hosts for [serverA.domain.internal]:22 / (none) debug1: client_input_hostkeys: searching /Users/snafu/.ssh/known_hosts2 for [serverA.domain.internal]:22 / (none) debug1: client_input_hostkeys: hostkeys file /Users/snafu/.ssh/known_hosts2 does not exist debug1: client_input_hostkeys: host key found matching a different name/address, skipping UserKnownHostsFile update 

The old host key(s) are obviously present in known_hosts – but why would that prevent the update?

If I comment out the old host keys in /etc/ssh/sshd_config, the host presents only the new key (as expected), and the client refuses it (as expected).

2
  • Did you restart the sshd after updating the key? Commented Oct 13, 2024 at 8:09
  • 1
    Yes, as stated in my question (did not include the restart command in the quote, though – corrected. Commented Oct 13, 2024 at 8:37

1 Answer 1

0

Damien Miller helped me solve the problem: Increasing the verbosity (ssh -vvv -o UpdateHostKeys=yes serverA) revealed a known_hosts entry linked to serverA's IP address (I had forgotten that I had connected to it by IP address at some point). Deleting this entry solved the problem; the new host key was stored in known_hosts when I connected to serverA again.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.