brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: UpdateHostKeys lets a server add its other host keys to your known_hosts

Linux
~/tips/tip-ssh-updatehostkeys-known-hosts

Host *

Lets a trusted SSH server hand you its additional host keys so known_hosts stays current.

A server rotates or adds a host key, and your known_hosts file never hears about it. Then the day the old key is switched off, ssh complains.

The UpdateHostKeys option controls whether ssh accepts notifications of additional host keys from the server after you authenticated, and adds them to your known hosts file. The values are yes, no and ask.

Host *
    UpdateHostKeys ask

With ask, ssh asks you to confirm changes to the known_hosts file. The man page says the option is enabled by default if you have not overridden the default UserKnownHostsFile and have not enabled VerifyHostKeyDNS. Otherwise it is set to no. On a plain setup you may already have it, and with a custom known_hosts location you do not.

It makes the day a server replaces an old key type easier. Your client has already learned the new key over the old, trusted connection, so no unknown-key question comes up later.

Updates arrive only after you authenticated, so the server is one you already trust. I would still be careful with a script that sets yes for a host you do not control, since that host can then add keys to your file. For hosts that are not mine I would keep ask. To see what a server has added afterwards, ssh-keygen -F host lists its entries.

Further reading: ssh_config(5), ssh-keygen(1)

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link