SSH key based authentication secure and convenient or is it? Well that seems really obvious that it is secure and convenient no passwords to be guessed and changed all the time, or that can be guessed logging on to servers much faster. But when done improperly it isn’t that safe and secure as it would seem.
When logging on to SSH servers using authentication agent forwarding for convenience so you could jump hosts using the same key. See nothing wrong with it? Still seems all good and secure? Well not that secure any more, as soon as convenience of the authentication agent forwarding comes to play a little issue arrises that a lot of people do not think about. Namely the key you used to authenticate to the server is now accessible to others on the server, not in the sense that they could copy it, but they can use it to authenticate to other servers where your key would be valid and that are accessible from that server. Although it requires escalated privileges to get access to it, it is still a problem. So where is this key located? It goes to the /tmp/ folder. As the following is an example from my test machine:
huxx@lnx:~# ls -la /tmp/ total 10 drwxrwxrwt 10 root root 3072 Feb 1 01:00 . drwxr-xr-x 23 root root 4096 Jun 2 2015 .. drwx------ 2 huxx huxx 1024 Feb 1 00:36 ssh-DhNiAzWTEV
huxx@lnx:~# ls -la /tmp/ssh-DhNiAzWTEV total 4 drwx------ 2 huxx huxx 1024 Feb 1 00:36 . drwxrwxrwt 10 root root 3072 Feb 1 01:01 .. srwxr-xr-x 1 huxx huxx 0 Feb 1 00:36 agent.18922
Is there a solution for it?
So is there a solution for the afore mentioned issue? Well luckily Yes there is. There are SSH key agents out there that actually ask for your permission first before allowing access to the private key. For Windows one such solution would be to use the KeeAgent plugin for the password manager called KeePass it allows to set a password/confirmation to be prompted for every time someone/something tries to access the private key. The same combination will also work on macOS with a bit of work by porting the Windows application using mono for Mac and adding ssh-askpass script to the system. The exact solutions will be shown in followup posts to come.
Solution for Windows users described here: https://www.huxxit.com/index.php/2018/02/02/safer-ssh-key-usage-windows-just-using-putty-pageant/
Leave a Reply