How to add SSH keys to Edgerouter

I use the wonderful Ubiquiti Edgerouter network router at home, its a fantastic machine, very powerful and uses linux, so can be customised and used from more tricks than was originally intended, I’m going to write up my favourites, to get started let’s first secure your ssh connection using an SSH key.

If you already have a key created, you can skip this bit. Customise with your email address, and call the file id_rsa. Make sure to backup the keys, you will use the public part to share with remote machines, they will match it to your private one stored on your machine.

cd ~/.sshssh-keygen -t rsa -C "your_email@example.com"

The first step is to copy your ssh public key to the ERL. Change to add your routers IP address below.

scp ~/.ssh/id_rsa.pub <ip-of-erl>:/tmp

After this you need to associate the public key with your user on the ERL. Sign into the router using over SSH using terminal, putty or iTerm.

configure loadkey <user> /tmp/id_rsa.pub commit save exit

Now you should be able to log out and then log back in using your ssh key and not have to use your password to do so.