I'm updating multiple Ubuntu systems to respond to Update your Bitbucket Cloud SSH Host Keys. tl;dr: Bitbucket updated their SSH keys, so the clients must update their .ssh/known_hosts
accordingly.
At first, I tried to remove the old entries like this:
ssh-keygen -R bitbucket.org
Unfortunately, this didn't work, because .ssh/known_hosts
has hashes "related" to bitbucket.org too, and those are not removed. I say "related" because these entries are not just hashed versions of bitbucket.org
(ssh-keygen -R
would remove those hashes too), but are hashes of the IP addresses of bitbucket.org, such as 2406:da00:ff00::22cd:e0db.
This is already very puzzling to me: I am 100% positive that the system have ALWAYS contacted bitbucket.org via its domain name and NEVER using its IP address explicitly.
Anyway: if I ssh-keygen -R 2406:da00:ff00::22cd:e0db
the hashed entry is removed, but bitbucket.org resolves to a wide range of IPv4 and IPv6 addresses, and I cannot know which one(s) are/are not hashed by every system of my list.
OK, so I decided to just truncate (echo > .ssh/known_hosts
) the files and add bitbucket.org to the list via curl https://bitbucket.org/site/ssh > .ssh/known_hosts
. It worked, but as soon as I try to use it... a new entry is created:
|1|9kAE7U7gEPwOs5jNQC3eMZY4hMw=|4GlyuBNqCjVq3Lk+SyBTGDed+8U= ecdsa-sha2-nistp256 AAAAE2VjZHNhL....
This is the hashed version of 2406:da00:ff00::22cd:e0db
, the IPv6 address resolved from bitbucket.org, and the key is exactly the same I already added for bitbucket.org!
It's alright for now, but this means that the next time a key rotation happens (from GitHub, GitLab or one of the other provider I use, maybe?) I will have to truncate the file again!
So, the questions are: why are the IP address related to the hostname hashed? Can I prevent it? Is it possible to -R
them all based on the associated hostname?