How to add new ssh keys with ros config set? (resolved)

hi there,

i have to add further ssh keys to an already existing rancheros server.
i guess needs to be an array but i don’t wanna make something wrong and lock myself out :slight_smile:

ros config set ssh_authorized_keys and how to add here multiple keys?

would be great to get an example how to add 2 new keys …

thanks for the help!

no risk no fun.
i tried it and figured out two ways how to add new ssh users to rancher os:

solution 1: ros config merge

create a new file with all ssh keys (also existing once!):

  • filename: ssh.yml
ssh_authorized_keys:
- ssh-rsa xxxx mail@domain.tld
- ssh-rsa xxxx mail@domain.tld
- ssh-rsa xxxx mail@domain.tld

command to add: ros config merge -i ssh.yml

solution 2: ros config set

ros config set ssh_authorized_keys “[‘ssh-rsa ssh-rsa xxxx mail@domain.tld’, ‘ssh-rsa ssh-rsa xxxx mail@domain.tld’, ‘ssh-rsa ssh-rsa xxxx mail@domain.tld’]”

its also required to add the new keys to /home/rancher/.ssh/authorized_keys for a persistent console.

hopefully this info could help others too …

cheers maik

4 Likes

This worked like a charm. Thanks a lot!