This tutorial will cover how to set up SSH via Putty on a UNIX-type box, so that you can log in using key-based authentication, as opposed to passwords.

Screencast: http://www.screencast.com/t/a7CqCCPtMOGu

Download Putty.exe and PuttyGen.exe.

Open up Putty.exe and configure a server that you can connect to. Stay connected.

Open up PuttyGen.exe.

* DSA tokens are deprecated and insecure. You should only use SSH-2 RSA keys.

* Use 1024 bits for insecure servers you don’t really care about. 2048 is good for most servers. Use 4096 bits if you have a good connection and you’re at least a little paranoid ;-)

Hit Generate. Move the mouse like mad over the box. This takes a LONG time for 4096 bit keys.

It is good policy to enter a Key passphrase. Then you’re doubly secure. But then you have to enter the passphrase in each time you login… What’s the point then? You can use Putty’s PageANT to only have to enter a keyphrase once every 30 min or once per login, but that’s beyond the scope of this tutorial.

Click Save public key and save it somewhre secure.

Click Save private key and save it somewhere really secure.

Copy the code in the textarea.

Go to the server you’re logged into.

* Make sure the ~/.ssh directory exists.

* Confirm the permissions are drwx——-:

* $ chmod 0700 ~/.ssh

* Create a file called ~/.ssh/authorized_keys and put the copied text into it. Optionally change the descriptor at the end. It’s important that this be on one single line.

Right click on your putty window bar and open up the new session box.

Load your session.

go to Connection -> SSH -> Auth.

Click “browse” near “private key”

**IMPORTANT*: Immediately go to Session, select your session and hit Save. Otherwise your changes won’t hold.

Attempt to login.

Successful password-less, key-based SSH login ;-) Enjoy!

[[Category:PHP_From_Beginner_to_Pro]]