Friday, March 24, 2023

Github updating its ssh keys

Today I learned that the Microsoft-owned Github decided to update its RSA SSH host host key but did not explain its reasoning. Why would it go through all of this trouble? Usually when a company does that, it is their way to cover that they were hacked or were compromised in some other way. That is not what is written in their blog, so we will have to wait for this to unfold.

"What does that mean to companies and developers depending on that?" Well,

  • If you created a SSH RSA keypair to authenticate against github -- so you can git push and git pull your repos without entering your password -- you probably wants to consider creating a new pair, deleting the old one, and using the new one. Ideally, this may also be an excuse to switch to an ECDSA-derived key such as ed25519 if you are able to. Sometimes this is hard because you may be dealing with a host that does not support that... not that have ever happened to me.
  • If you have received the github RSA pub host key, which was added to your .ssh/known_hosts (if you are using Linux, OSX, and some UNIX variation) file, you will need to delete that entry and get github feed you a new one. Of course, you want to ensure you are getting the proper github key, not one from someone impersonating it.
  • If you use Windows, well, let me get back at you on that later.

Now some developers will argue that relying on known_hosts has caused more failures of working software than preventing faked host access since SSH was originally written. Their proposed way to deal with that is to tell ssh not to check the validity of the host key. In Linux, OSX, and other UNIX versions that would mean to disable that in ~/.ssh/config. If you want to disable the Key checking to all ssh connections, you could do something like (the boldface lines are the most important parameters)

    Host *
           UserKnownHostsFile /dev/null
           StrictHostKeyChecking no
           LogLevel error

While I understand that the above is a clever way of stopping suck pesky keys from hampering your style, disabling security for the sake of convenience is never a good solution. The more time-consuming solution is to remove the offending keys in ~/.ssh/known_hosts so you can ensure you are getting the right key, not a key impersonating the site you want to connect to, which in this case is github.

Fun fact: given that I saw the following message, I think they are not only changing the RSA key:
Warning: the ECDSA host key for 'github.com' differs 
from the key for the IP address '140.82.121.3'