Adam O'Grady

SSH: No Password Access

I’ve always loved accessing things via SSH, it’s nifty, quick and way more secure than trying to telnet into a device. Something cool that I’ve setup recently though is SSH access sans password! It’s not incredibly difficult and the end result has some nifty benefits, particularly the ability to script SSH sessions with commands without you needing to be there to type a password. The first one that came to mind for me was cron and rsync combos for regular, secure, remote backups but it also allows you to do some neat stuff with PaaS (Platform-as-a-Service) implementations like Heroku or in my case, Dokku.

So firstly, jump on the client device that will be initiating any SSH sessions. Then run the following command, substituting in your own email address:

$ ssh-keygen -t rsa -C ""

Let it save in the default location (~/.ssh/id_rsa) then press enter twice without entering in a passphrase (to allow access sans password). This will create two files, id_rsa (your private key, DO NOT GIVE THIS OUT) and (your public key which you’ll put on the server you want to access) and show you some neat ASCII art based on the generated key.

Now run the following and copy the output:

$ cat ~/.ssh/

It’s time to SSH into your server as the user you want to be able to access. Open the file ~/.ssh/authorized_keys and paste in your public key. Save and exit this file and then terminate your SSH session. Next time you go to re-initiate it, you should be logged in immediately without requesting to authenticate via password.

I hope this tutorial is of some use to you! If you have any questions or queries, feel free to Tweet me at @adamjogrady or you can find my other contact details on my website.