'

Howto SSH from Windows to Linux without Password by using PuTTY.

April 22nd, 2012 by Andrea Matesi 14586 Views

Intro.

Anytime you have to gain access FROM this Windows box to that Linux box, copy/pasting that non-sense password into PuTTY is tedious, frustrating and time-consuming.

But there is always a way to improve your productivity. You'll just need to put your SSH keys to good use.

This 3-way process will allow you to gain access to your favourite OpenSSH Server-enabled Destination *NIX Box without having to re-type your usual password anytime (this is aka passwordless SSH access).

It works this way:

  • First you'll have to generate your keys.
  • Then you'll copy one of your keys to the destination Linux box.
  • Verify if it works.

But bear with me: It'll be a very basic tutorial.

Generate keys with PuTTYgen.

The process involves two systems: your average SOURCE Windows box (be it XP, Vista or 7 or successors doesn't matter, as soon as PuTTY & Co. works for you), and your average DESTINATION Linux box.

Download and install PuTTY with the included installer (I am suggesting you the installer because you'll also need the other "P-programs" enclosed).

ue puttygen to generate your key pair.

Execute PuTTYgen.exe to generate a new key (no need to use this program every time, it's just a "use-and-forget" kind of toy).

To generate a new key, from the main screen, over the "Parameters" section, make sure "SSH-2 RSA" is selected, then press the "Generate" button: an increasing progress bar will appear. Make some "digital noise" (ie.move your mouse in and around the bar to generate some human randomness for your key).

Once the bar is full, you will be presented with your scratchy new key. Input a comment for your key (ie.joe@myWinBox).

this is your PPK, select the public lines and paste them in linux

You'll need to save this key somewhere. Push the "Save private key"-button and browse for a sane place where to store it (ie,"C:\Documents and Settings\Joe\my\super\secret\folder\with\ssh\keys" - so nobody will find it!).

Don't close PuTTYgen yet, keep it open (or reduce it to icon), because you're going to need it again.

Now let's focus our attention to the Linux server you're willing to gain access to.

Execute PuTTY as usual and just LOAD your saved session (don't open it yet), since we're going to configure some options.

Save you LINUX username into PuTTY.

From the selection tree, choose the "Connection" -> "Data" branch and type your linux username inside the "username" textarea  so you won't have to type it again every time.

Where to specify your key path such as PuTTY can use your keys.

Expand the "SSH" branch and choose "Auth" ("Connection" -> "SSH" -> "Auth"), then click the "Browse..." button to point it to your PPK-file.

Return to your main PuTTY screen ("Session") and SAVE your profile, then, finally, Open the session to your remote linux host and gain access to it with your password (as usual).

Copy the generated keys to your destination host.

At this point, you'll need to copy the public key section content from PuTTYgen to your remote Linux host, so you won't have to type your password again.

"cd" to your home folder (ie./home/andy) and open the "authorized_keys" file (ie. nano .ssh/autorized_keys).

Back on your Windows box, from PuTTYgen, select the public key part with your mouse, copy it then paste it inside the "authorized_keys" file you just opened previously with PuTTY/nano. An important thing to take care at this step is to look for the CRs an LFs. Make sure your public key lies on a SINGLE LINE (verify with your "Home" and "End" keys).

Verify...

Once you're sure you copied your key correctly.

Close your remote session and reopen it: if you're not asked for a password, then it worked, else...wash, rinse and repeat until it works!

ubuntu

Good achievement passwordless SSH, uh?

Bonus TIP: Have your NumLock perform correctly!

Once you're at PuTTY customizations, why not have your keypad work as intended?

When left at default, PuTTY will use your Keypad to send some escape sequences.

This tip will simply disable this feature.

You'll simply go to "Terminal" -> "Features" then check the "Disable application keypad mode" and Save!

Disable application keypad mode for NumLock to work as expected!

Posted in LINUX, Microsoft, System Administration, Tips and Tricks. | 1 Comment »

One response to “Howto SSH from Windows to Linux without Password by using PuTTY.”

  1. This helped more than you can imagine but took forever to find XD

    -Thanks