Peter's Blog

Redefining the Impossible

open-ssh and putty keys.


Putty is a simply great ssh client and works nicely with open-ssh, which is found in Ubuntu Linux, Site5 and just about everywhere.

A nice feature of ssh is the ability to generate a public key that can be used to log into a server without having to give a password, or as extra secutiry in addition to the password.

Here is a procedure for creating ssh keys that can be used in both open-ssh and putty:

  • On windows, install the open-ssh package with Cygwin
  • execute the command
    ssh-keygen -t ssh-dss
    
    to generate the dss key. You may need to create the directory ~/.ssh in Cygwin bash for this to work. This will create a file in this directory called id_dsa.pub
  • use sftp/ssh to copy the id_dsa.pub file to your ssh server box. Put the contents of this file (which is one big long line) at the end of a file called ~/.ssh/authorised_keys2, adding it to any other keys that are already there.
  • back on windows, execute the command 'puttygen', from the putty site.
  • In putty gen, use file/load private key to load in the file ~/.ssh/id_dsa
  • Choose 'save private key' and store it somewhere handy where putty can find it. You may be prompted to enter a passphrase. This is a password used in addition to the key when connecting to the server. If the passphrase is blank then you don't have to enter it, the connection will be automatic.
  • Open putty and enter the details of the server you want to connect to (address etc)
  • In the 'connection' settings, enter your login name in 'Auto-login username'.
  • In Connection/SSH/Auth, in the box 'Private key file for authentication' load the putty private key file.
  • Save this configuration so you don't have to do it again.
  • Click 'open'

Your life won't be the same again.


Breezer Says:

over 3 years ago

You might already know of it, but with ssh you also get another way to speed up connections from the prompt to another machine. I only discovered it recently, and it's saved me a whole 4 characters each time (wow!). Ok, not so much gain but kinda handy.

Along with the other ssh binaries, you get ssh-argv0. Which does as it says (if you can work it out) - symlink to it or alias it with a command the name of the machine you want to login to eg.

ln -s /usr/bin/ssh-argv0 machinename

and whenever you run the 'machinename' symlink, it will act like "ssh machinename". I also set up my personal (or could use system-wide) ~/.ssh/config so it knows which user and which port I log in to various machines with by default (see man page for ssh_config).

Peter Says:

over 3 years ago

Hadn't heard of this one and I'll have to try it. Thanks.

Peter

Comments are Closed