Saturday, September 10, 2011

SSH Passwordless login

Passwordless login is a great feature when you are performing regular administration between servers. I use it often, but rarely go through the process to set up.  Therefore I usually forget what needs to be done and I end up scouring the web for instructions.   So here is what I ended up with.

I have my local system, we'll call it Home and then I have a remote server, we'll call it Remote (nor very creative, I know).  In this case both servers are running Ubuntu 10.04.

If you haven't done this before on Home you'll need to generate authentication keys (step 2).  Otherwise skip this step.

  1. Log into Home (local computer) as the user you want to user for passwordless ssh
  2. Type: ssh-keygen -t rsa
    • Default directory for keyfiles will be ~/.ssh/ (your home directory)
    • Leave passphrase blank!
  3. Copy the contents of .ssh/id_rsa.pub (there should only be one line) to your home directory .ssh folder on the Remote server.  The file will be called ~/.ssh/authorized_keys
    • Check first to make sure there is a .ssh folder in your home directory on Remote
    • Type:  scp id_rsa.pub remoteuser@Remote:.ssh/authorized_keys
That's it! You can how ssh directly to your remote user @Remote without a password prompt.