30
October

SSH Key Exchange (SSH no password)

I’m not sure if it was just me being a bit dense or the fact that tutorials on the subject where really confusing, but I’d always struggled to get this working. So, I thought that now I’ve cracked it I’ll do my own little tutorial for others out there that may still be a little bit stuck.

  1. The first thing you have to do is generate the keys, this is done on the machine that will be connecting from:
    ssh-keygen -t rsa
    This will generate the private and public keys need, they will be put in “~/.ssh/” by default called “id_rsa.pub”(the public key) and “id_rsa” the private key.
  2. Now you need to copy this public key, “id_rsa.pub”, to the machine you will be connecting to, choose what ever method your comfortable with, ssh, ftp, smb – what ever ;-)
  3. Now all you need to do is add this key to the file “~/.ssh/authorized_keys2″, the easist way is:
    cat id_rsa.pub >> ~/.ssh/authorized_keys2
    Then your done, you should no longer be prompted for a password when connecting.

Note: if this is the first time you are connecting it will still prompt you to add the machine to known hosts.