What is the correct way to add a public ssh key?

In other Linux platforms, I would add my SSH RSA public key to the ~/.ssh/authorized_keys file. But when I go in to the VyOS .ssh/authorized_keys file, it says:

vyos@VYOS# cat .ssh/authorized_keys
# Automatically generated by Vyatta configuration
# Do not edit, all changes will be lost

What is the correct way to add a key in VyOS that will survive a reboot?

from op mode
loadkey

Thanks syncer. This is what I get when I try that:

[code]vyos@VYOS:~$ loadkey vyos mykey.pub

Invalid command: [loadkey][/code]

If I try tab completion via sudo, the closest that I see is “loadkeys”:

[code]vyos@VYOS:~$ sudo load
loadfont loadfont.bb loadkeys loadkmap loadkmap.bb loadunimap

vyos@VYOS:~$ sudo loadkeys -h
loadkeys version 1.15.2

Usage: loadkeys [option…] [mapfile…]

Valid options are:

-b --bkeymap output a binary keymap to stdout
-c --clearcompose clear kernel compose table
-C <cons1,cons2,…> --console=<cons1,cons2,…>
the console device(s) to be used
-d --default load “defkeymap.kmap”
-h --help display this help text
-m --mktable output a “defkeymap.c” to stdout
-q --quiet suppress all normal output
-s --clearstrings clear kernel string table
-u --unicode force conversion to Unicode
-v --verbose report the changes

[/code]

Here is my VyOS version:

vyos@VYOS:~$ show version Version: VyOS 1.1.5 Description: VyOS 1.1.5 (helium)

You will need to upgrade to 1.1.7
be sure that you run command from op mode and not from configuration mode
in configuration mode you will need to prepend run
run loadkey vyos /path/to/id_rsa.pub

Thanks syncer. Is there a way to do it in my current version, even if it is not persistent across a reboot?

It’s same i think down to first versions
still i will recommend update (that should take not much time)

I know this is an old question, however, I believe this will really make it simpler for new users:
In my scenario:
pc1 = 192.168.0.3 (linux) username = user1
vyos = 192.168.0.101 (version 1.1.8) username = user1

  1. login to vyos
  2. switch to configuration mode
  3. type the command: loadkey user1 scp://user1@192.168.0.3/home/user1/.ssh/id_rsa.pub

Output below:
[edit]
user1@vyos1# loadkey user1 scp://user1@192.168.0.3/home/user1/.ssh/id_rsa.pub
Enter host password for user ‘user1’:
######################################################################## 100.0%
######################################################################## 100.0%
Done
[edit]

Now:
user1@pc1:~$ ssh 192.168.0.101
Welcome to VyOS
Linux vyos 3.13.11-1-amd64-vyos #1 SMP Sat Nov 11 12:10:30 CET 2017 x86_64
Welcome to VyOS.
This system is open-source software. The exact distribution terms for
each module comprising the full system are described in the individual
files in /usr/share/doc/*/copyright.
Last login: Sat Aug 11 16:17:21 2018 from 192.168.0.3

No ssh prompt and I can login using my rsa public key. Hope this helps.

Sincerely,

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.