A place to breathe

Tuesday, November 27, 2012

Auto-logging to remote server using private / public key pair on Windows

Often times, we're lazy to key in the username and password everytime we want to log in to remote servers.

The usual scenario is like this:

You're from Windows machine, and your work is on Unix/Linux server somewhere in other parts of the world. You download PuTTY, and you want to remote login. You download WinSCP, you want to securely transfer files.

After a while, you get tired of typing the username and password. What do you do?

As the laziness of programmers always drives the world forward - here it is: Appointing an "agent" to log it in for us.

How does this work?

1. Download PuTTYgen (search on Google)
2. Generate Public/Private key pair, put in paraphrase (usually your password)
3. Save your public and private key (*.ppk) somewhere safe in your computer.
4. Copy the "public key" on the PuTTYgen into a notepad. 
5. Remote login to your server, create ".ssh" directory, and copy the "publickey" into a file called "authorized_keys" . Save the key into the ".ssh" directory in your home directory. 
6. Download Pageant (go search on Google)
7. Run Pageant - now it runs and resides in your taskbar.
8. Right click, and Add Key. Browse into your private key you just created in step 2.

9. Create new session (or just run from command prompt:
C:>pageant.exe -c /putty.exe )

10. Put your details - username, password, and private key. Save session.

Now when you right click pageant, (the little icon with hat), it will prompt your username and when that matches, will auto login right away.

10. You can also repeat the step for WinSCP, and store the session. When you click on the stored session, WinSCP will auto-login for you.

Save 15 minutes in your life daily, and go get vacation with time saved!


No comments:

About Me

I'm currently a software engineer. My specific interest is games and networking. I'm running software company called Nusantara Software.