Login without password using Putty and SSH
The purpose of this article is to describe how to use Putty and RSA public/private keys to login to a server without the use of a password.
Determine if you are running 32 or 64 bit OS
In windows open the computer properties window by clicking Start then right-clicking computer and finally click on ‘properties.’ A new window will open detailing your computer’s information. Look under the System section for ‘System Type.’
Now download the correct version (32 or 64 bit) of both putty.exe and puttygen.exe from http://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
Putty.exe is the SSH client and puttygen.exe is an RSA and DSA key generation tool. You will need an RSA key to login using SSH without a password. The following procedure is used to generate the RSA key.
1) To generate your RSA keys, open the puttygen.exe tool.
2) Click on the ‘Generate’ button. After you click the button, the key generator will ask that you move the mouse inside the blank area of the window. As you move the mouse, the progress bar will grow until the tool has captured enough random information based on your mouse movements.
3) When complete, you will see the window update with information about your new public key. Make sure the 'key comment' will not conflict with any other public keys already on the server (Not likely unless several people use this process on the same day to access the same account on the server) .
4) Click on the ‘Save public key.’ You will upload this key to the server you wish to login to, so pick a useful name like ‘mypublickey’
5) Click on the ‘Save private key.’ Puttygen will open a pop-up window asking if you are sure you want to save the key without a passphrase to protect it. Choose ‘Yes.’ This is the key that identifies your computer to the server, so store it in a secure place on your computer. You will need to enter this file into putty later, so make sure you remember where you saved it.
6) You are now finished with the puttygen.exe tool. Close the program.
7) Move your public key from your local computer to the server using an (S)FTP client like Filezilla. Save the file in your home directory.
8) Open putty.exe and login to the server as you normally would.
9) If you have never used public/private keys to login from another system, you will need to create a new directory under your home directory called .ssh Use the following command
10) Now add the public key you generated earlier to a file called ‘authorized_keys’. If you have already setup passwordless login from other hosts then this file might already exist. Use the following command from your home directory
ssh-keygen -i -f mypublickey >> .ssh/authorized_keys
11) Set the permissions to restrict other users on the system from accessing this directories and files with the following command
chmod go-rwx .ssh .ssh/authorixed_keys
12) Now you can remove the original public key file with the following command
13) Logout from the server then close putty (if it doesn’t close automatically)
14) Now we can configure putty to use the public/private keys to login without a password
15) Open putty. At the configuration window, navigate to Connection->Data. In the Auto-login username field enter your username on the server
16) Now navigate to Connection->SSH->Auth. This is the screen where you tell putty where your private key is located. Click the ‘Browse’ button and find your private key.
17) Navigate to the ‘Session’ screen. Complete the host name field. Make sure the port is 22 and the connection type is SSH. Next enter a name in the ‘Saved Sessions’ field.
18) Click the ‘Save’ button in the middle of the window on the right side. You will probably want to click the ‘Open’ button because of its location, but that will not save your configuration.
19) Now click the ‘Open’ button. You will see the following pop-up window. Click ‘Yes’
20) The next time you open putty, you will see your saved configuration in the space next to the ‘Save’ button, identified with the name you chose when saving the configuration. You can double click the name to open a session to the server without using a password.
21) If you have additional servers to you want to login to without a password start with step 7 for those servers.