Using Puttygen to create a ssh key and passwordless login with putty to Centos.

The ssh password-less login works in a  simple way. Though sometime people find it confusing.

The basics:

>  Client side has a private key pointed to by

>  Server side has the public key of the client.

 

On your client box create a public and private key set using (for putty) puttygen. (In linux all you need to use is ssh-keygen.

On the server :

If not already there create a folder /<user_home>/.ssh  e.g. /root/.ssh and in that folder create a file named authorized_keys. This file will store all the public keys that a given user with matching private key, can use. Easy way echo “<paste here>” >  ~/.ssh/authorized_keys

 

mkdir ~/.ssh

echo “ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIBz7Pml97wSzFMSr1W84rA0Mm8MY8I1jKdAmMcF4sw5GilormHJQRYI8siT1XPaLJFAO20ziZg9YrJFp+roKC34gpe1myFWUz944iucrLIQznZwPDJbMKxQXwzj1LUPmt7eXPzwM1ztvcG8HOoZlTt2B6hOAVWAHxlZNzPq/9y1Fw== rsa-key-20131124” > ~/.ssh/authorized_keys

chmod 600 ~/.ssh/authorized_keys

chmod 700 /~/.ssh

 

Once this is done you can add the private key to the client under ssh -> Auth -> private key.

Select back the session and save it as usual in Putty.

If you get the error “Server refused our key” it probably means you still have SElinux enabled.

To fix this:

restorecon -R -v /root/.ssh

 

That should work.

nJoy 😉

 

 

Write a Reply or Comment

Your email address will not be published.