SSH Key handling on multiple servers environment

To have fluent access to securely walk through you servers, I have collected here some helpful instructions. I’m not going to go too detailed and the simplest things but some that I have found useful.

First of the tools, on linux and other unix machines and mac, I use the basic OpenSSH tools that there are, so ssh, scp, ssh-keygen and so on. On Windows I use putty family tools + some extra tools like Connection Managers.

So first create keys like one with passphrase and one without:

ssh-keygen -t rsa -b 4096

Then I rename them some way like adding userid on the name and ppk extension for the private file to make it easier to handle in Windows machines. I also modify the comment string to have something useful there.

On Windows you can use puttygen.exe for the same.

Then of course make sure your private key is only as few places as possible and in trusted places. I keep mine only on my trusted personal devices.

Then with the following command I copied the files to servers where I need them.

cat ~/.ssh/id_rsa_some.pub | ssh userid@servername.fi "cat >> ~/.ssh/authorized_keys"

Now if you need to log on to many machines loops, you can do that with Agent forwarding. In ssh you can simply do this with -A switch, and in Putty you can enable that on the profiles with Connection – SSH – Auth – Allow agent forwarding.

After that you have on your favorite laptop or desktop private file once, and there you will use eg. in Windows pageant to load that key by giving password for authentication only once. Then you will have the agent program running and with those Agent forwarding enabled, you will get the authentication to all your machines.

There is some security considerations here to take in account so you should consider that also when doing this.

 

Author: Veli-Pekka Lehtosaari

Veli-Pekka Lehtosaari, most call me VP, age 44 (2016), CEO, Consult, M.Sc.(Tech), Electronics, ICT 1997, Married, 2 children (Girls), Hobbies: ICT, Motor racing, Snowboarding

2 thoughts on “SSH Key handling on multiple servers environment”

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.