Besides auto login into ssh with putty by specify password on the command line as we have done in this post, the tutorial uses the private/public key method to do the auto login.
Setup on the local computer
- We need putty.exe and puttygen.exe, all can be downloaded here: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
- Run puttygen.exeto generate the private/public key pairs:
Make sure you select the SSH-2 version key in the bottom, you can also choose from RSA or DSA
- Save the private key on your local computer, find a folder which is safe, keep in mind that if you leak this private key to public, someone else will also be able to login to your server.
- Open putty.exe, go to Connection->SSH->Auth, load the private key:
- Go to Session, create a session with the name “remote_server”:
Setup on the server side
- Copy the content of the public key you generated in puttygen.exe
- Putty into the server as you do normally, create a file: ~/.ssh/authorized_keys, if the folder .ssh not already exist, create it.
- Paste the content you copied from step 1 into the file and save exit.
Now, open putty.exe, double click on the “remote_server” session, you will be able to login to the server without password, but it will prompt you to type in the user name. To fully automate the login process, let’s create a shortcut to the putty.exe on your desktop:
C:\putty.exe -l username -load "remote_server"