Constantinos' Blog

SSH Passwordless Authentication

By Constantinos Michael · January 18, 2007

SSH and the file transfering protocols on top of it (SSHFS, Konqueror’s fish://, SFTP and scp), were a big deal for me before I switched from a Linux to a Mac notebook. So the FUSE port for Mac, or MacFUSE, is a really exciting, much wished-for addition to the great free software library available for the Mac.
What’s more exciting is that it’s developed here at Google.

There’s a couple of ways to make this work even better for you, one of which is SSH Passwordless Authentication, or Key Authentication. Here’s how you can set it up:

  1. Generate an SSH key pair. Use either an empty passphrase or one that you can easily type (a short password is fine, because an attacker would still need to use your key!)

    You can do this by typing this into the terminal:

    ssh-keygen -t rsa
  2. Now, create a script that will install this key on remote locations by pasting these lines into the terminal:
    sudo touch /usr/bin/ssh-install-key ;
    sudo chmod a+w /usr/bin/ssh-install-key
    echo "cat ~/.ssh/id_rsa.pub | ssh \${1} \"cat - >> ~/.ssh/authorized_keys\"" \
         > /usr/bin/ssh-install-key
    sudo chmod a-w+x /usr/bin/ssh-install-key

Now you can install your key to whatever server you please! Just do

ssh-install-key user@someserver.com

Enter your password as many times as you’re prompted, and then just login with

ssh user@someserver.com

If you’ve put a non-empty passphrase, you should be asked for the passphrase; otherwise, you’re already logged in!



©2012 Constantinos Michael - About me - RSS - Creative Commons license