DEV Community

Cover image for Enable key based SSH login to your EdgeRouter
Wietse Wind
Wietse Wind

Posted on

Enable key based SSH login to your EdgeRouter

If you want to login to your EdgeOS router using your SSH identity instead of a password, you can. Make sure you already have your SSH identity (key, pubkey). You'll need your pubkey later on to whitelist it in your EdgeOS config.

To configure SSH login using your your ssh key instead of a password, SSH into your EdgeRouter:

ssh {your-webinterface-username}@{your-router-ip} -p 22
Enter fullscreen mode Exit fullscreen mode

Eg. ssh johndoe@192.168.1.1 -p 22

When logged in, start configuration mode:

configure
Enter fullscreen mode Exit fullscreen mode

This tutorial assumes your username (to access the EdgeOS web interface (and SSH, just now)) is johndoe, replace johndoe with your actual username.

Now configure your SSH login key type:

set system login user johndoe authentication public-keys johndoe@device type ssh-rsa
Enter fullscreen mode Exit fullscreen mode

Eg. set system login user myAdminAccount authentication public-keys myAdminAccount@myMacbook type ssh-rsa

Now add your public key. The value to add after key in the command below should be the Base64 string that's usually in your id_rsa.pub, without the ssh-rsa prefix, and without the hostname@device appended.

On OSX you can get this value using:
cat ~/.ssh/id_rsa.pub|cut -d " " -f 2

set system login user johndoe authentication public-keys johndoe@device key AAAAB.........
Enter fullscreen mode Exit fullscreen mode

Now commit your settings:

commit
Enter fullscreen mode Exit fullscreen mode

Open a second terminal window to check if you can sign in using your SSH identity, without a password. If everything works, you can save & exit:

save; exit
Enter fullscreen mode Exit fullscreen mode

Done πŸŽ‰

Top comments (0)