Putty / Puttygen / SSH Keys

By | January 20, 2011
  1. Run Putty Key Generator (puttygen.exe) and create and save keys (private as .ppk, public as .public).
  2. Copy the text in the window labelled “Public key for pasting into OpenSSH authorized_keys file:”
  3. Log onto server and past the key into a users authorized_keys file and save
  4. Open putty and navigate to Connection -> SSH -> Auth. Set Private key file to the .ppk file you saved in step one.

To revoke a key simply remove the relevant line from authorized_keys.

Potential Problems
Check the permissions on your home directory, .ssh directory, and the authorized_keys file: If your ssh server is running with ‘StrictModes on’, it will refuse to use your public keys in the ~/.ssh/authorized_keys file. Your home directory should be writable only by you, ~/.ssh should be 700, and authorized_keys should be 600. Check your home direcotry is set to /home/%username% as some service accounts have different default paths for their home directory (i.e. /var/www)

Get sshd debugging to the console (or already active putty session) by executing the following command  “/usr/sbin/sshd -d -p 1234” on the remote host and connecting to it on port 1234. Check your firewall allows connections to port 1234!