Tuesday, September 22, 2009

set ssh key gen in Putty

Download PuTTY and PuTTYgen

Open PuTTYgen Select SSH-2 RSA Click ‘Generate’ Save the Private Key Click ‘Save private key’ (you do not have enter a password) Save the private key in location easy to remember.

Copy public-key Select all text in the public key area. right-click and select copy Configure the server settings in Putty Open Putty Click Session (left column) Enter the server hostname or IP address Enter a name under ‘Saved Sessions’ Click Connection > Data (left column) Enter ‘root’ for the auto-login username Click Connection > SSH (left column)

Select ‘2' as the Preferred SSH protocol version. Click Connection > SSH > Auth (left column) Browse to the private key from step 4. Click Session (left column) Click Save Open a session with the server Open PuTTY Select the session saved earlier. Click ‘Load’ Click ‘Open’ Login Add client public key. You should still have the public-key in the clip-board from step 5. Open the authorized_keys file on the linux server

[root@server]#vi ~/.ssh/authorized_keys2 Press the ‘i’ key to insert in vi. Go to the bottom of the file and right-click on the putty screen (This should insert the public key generated with PuTTYgen) Press the ‘esc’ key to get out of insert mode in vi. Press ‘:’ to enter command mode in vi Type ‘wq’ to write and quit vi Now, you should be finished. Let’s test. Open PuTTY Select the session saved earlier. Click ‘Load’ Click ‘Open’ If you were able to login without entering your username and password you are finished!!If not, please continue to troubleshoot. Troubleshooting: If you do not have a /root/.ssh folder, we will have to create one and set the permissions:

[root@server]#mkdir ~/.ssh
[root@server]#chmod 700 ~/.ssh

If you do not have a authorized_keys2 file, we will need to create one and set the permissions:
[root@server]#vi ~/.ssh/authorized_keys2
[root@server]#chmod 644 ~/.ssh/authorized_keys2

If you get an error that the key was rejected, you need to make sure the permissions are set correctly on the .ssh directory and authorized_keys2 file.

[root@server]#chmod 700 ~/.ssh
[root@server]#chmod 644 ~/.ssh/authorized_keys2

No comments:

Post a Comment