Linux – SSH passwordless login with putty
Posted by Josh on Mon 14 Aug 2006Categories: Linux , SSH - [20] Comments
For Linux administrators that use Windows for their desktop OS, Putty is an invaluble tool. This tutorial will help you save time administering your servers without having to login to provide a username and password each time.
Click to play tutorial:
- Download PuTTY
- Download 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


July 2nd, 2007 at 3:39 am
Hello! Good Site! Thanks you! sehjyoazcgby
July 2nd, 2007 at 3:54 am
Simple one but very valuable one for linux administrators..
Thanks man
August 20th, 2007 at 2:30 am
very helpful, thanks
January 8th, 2008 at 12:34 pm
Hi,
Thanks for putting up such a helpful video.
what should I do if I get a prompt from putty saying “a new key has been created for a new host?”
January 8th, 2008 at 1:42 pm
If you get a prompt about a new key, just accept it. The happens the first time you connect to an ssh server.
April 2nd, 2008 at 3:08 pm
Could you do this with a Cisco switch? I’d love to be able to use this with KiwiCat Tools to securely automate config backup on my switches.
April 4th, 2008 at 11:05 pm
I do not think it is possible to use public-key encryption for login authentication on Cisco routers or switches.
However, I will love to be proven wrong. I would also like this feature.
Josh
November 17th, 2008 at 9:17 pm
[...] set up passwordless logon between your machine and the Fedora box. You can follow the guide here blindhog.net Linux – SSH passwordless login with putty SSH into your box and login as root (remember sudo may not work initially like Ubuntu, you might [...]
February 10th, 2009 at 8:46 pm
Hi, thanks for your tips.
March 9th, 2009 at 5:10 pm
Thanks – very straightforward instructions.
Question – what happens once the password on the account expires? Or will that still matter as long as this is set up?
March 12th, 2009 at 5:25 am
wellington,
I don’t think it matters. I am fairly certain expiring passwords do not apply to public key encryption.
Josh
May 16th, 2009 at 10:51 am
thanks,
I couldn’t figure out why it would work on one server and not another then I read your document and saw the make sure the authorized_keys file is 644, sure enough it was 666 somehow. I changed it and presto fedora is happy with me.
July 15th, 2009 at 6:23 am
Very clear!!! Great work, Finally i get it
November 24th, 2009 at 5:22 pm
Thanks man,
Its really simple and user interactive. Great job..
December 16th, 2009 at 4:19 am
Thanks for the help. Its really very simplified and well written process doc.
March 8th, 2010 at 11:57 am
Thanks a lot man.
this worked for me
March 25th, 2010 at 12:32 pm
Brilliant! Thanks!!
March 25th, 2010 at 12:33 pm
btw, excellent set of instructions
June 23rd, 2010 at 11:57 pm
Such a detailed description. Even a new comer to Windows/Linux would understand it. Thanks a lot..
July 24th, 2010 at 8:43 am
Top Tips there. I knew the process but just wasn’t working for me. Copied the key from the puttygen interface et voila!