Add an SSH Key to Ubiquiti EdgeRouter

Table of Contents

I had a bit of trouble adding an ssh key to my Ubiquiti EdgeRouter 6P. I kept getting

Not a valid key file format (see man sshd) at /opt/vyatta/sbin/ line 96, <$in> line 1.

Turned out that the key needs to:

  • have a comment
  • not have any spaces in the comment
  • be on a line of it’s own in the imported file (e.g. do not add a newline at the end)

for loadkey to accept it.


While my normally used pubkey has spaces in the comment, this was an easy fix once I knew what Vyatta’s problem is. I edited the import file to look as follows

ssh-rsa AAAAB3Nza…U6WQPNk= private_key


Once these conditions are met, save the key in a file on the EdgeRouter (e.g. /tmp/my_pubkey) and then import that file as follows;

loadkey <user> /tmp/my_pubkey