Sunday, 5 February 2012

ssh passwordless authentication without keys

ssh passwordless authentication without keys

Imagine ever wanted to avoid the hassle of typing in the password while connecting to servers using ssh? Here is a really simply neat trick that will demonstrate how easy it is to accomplish it so it does not ask for password. And as a bonus, you will notice that the connection is surprisingly much faster than you originally thought. No, it is not about ssh keys.

Suppose you could control the master which would permit you to enter the door without a key and the path it takes is always the right hand path. While you are thinking about it and saying to yourself what it has to do with ssh, allow me to tell you that you will realize once you have read the whole article how it is going to help you a lot in understanding passwordless authentication using this method.

The first thing we need is simply two lines in .ssh/config inside your home directory. If the file is not there, just create it. So the two magic lines are:

ControlMaster auto
ControlPath ~/.ssh/master-%r@%h:%p

Now connect to any host and it will ask for password. What the heck? It still asks for password, I heard you saying. That’s alright. Just put in the correct password and leave that terminal open. Open another terminal and try to connect to the same host again as in the first terminal and voila the magic…

While you are thinking about how just two key words ControlMaster and ControlPath allowed you to connect to a host without password and also much faster, let me throw in another neat trick.

If you ever wanted not to have to open another terminal, simply connect as shown below and the ssh will go into background

ssh -N -f host


Enjoy Vivek Creations :)

No comments:

Post a Comment