25 Nov 2009
SSH
Secure SHell allows a user to log in to a remote system to do command line stuff.
SSH without a password (Windows)
If logging in frequently to boxes, typing your password every time can get very tedious. Here’s a quick guide to setting up private/public key authentication using PuTTY, Pageant and PuTTYgen.
1. Download tools
Visit the PuTTY website and get the 3 required tools: PuTTY, Pageant and PuTTYgen.
2. Run PuTTYgen
Run the PuTTYgen tool to generate a key. This should be pretty obvious; you click generate and do some mouse-wiggling. When the key is generated, save both the private and public keys.
3. Copy your public key to the target machine
SSH into your target machine using PuTTY or command-line ssh if you prefer, then make sure you’re in your home directory
cd ~/
Check you have a .ssh directory, and if not, make one
ls -a | grep .ssh mkdir .ssh cd .ssh
Next up, open the public key file in wordpad or similar and copy the whole contents, then paste it into a new file called authorized_keys2 on the remote system using vi/nano/cat etc, then create a soft link called authorized_keys. Check if this file doesn’t already exist! If it does, don’t overwrite it, paste into the existing file.
cat > authorized_keys2 ln -s authorized_keys2 authorized_keys
3a. Possibly convert the file
I had a problem where even after providing my public key, I was still prompted for my password. A quick search pulled up this page, which suggested that something was getting buggered during the copy/paste phase.
ssh-keygen -i -f authorized_keys2 > authorized_keys2NEW rm authorized_keys2 mv authorized_keys2NEW authorized_keys2
This didn’t work at first (UUEncode error), as I’d created my file using cat, so I recreated it using nano and re-ran the command. All was now good.
4. Load the private key in pageant
Now run the pageant program and open your private key (right click on the icon in the system tray). Now when you run PuTTY, you will no longer be prompted for a password.