How to pass multiple SSH public keys with `linode-cli linodes create`

Linode Staff

According to linode-cli linodes create --help

Arguments:
--authorized_keys: A list of SSH public keys to deploy for the root user on the newly-created Linode.

How do I format this list to use multiple SSH public keys? When I include the quoted text of a two-line existing (and functioning) authorized_keys file, I get the following error:

authorized_keys SSH Key 1 must not be multi-lined.

I'm using this format:
"ssh rsa KEY user@host","ssh rsa KEY user@host"

This is accepted, but the authorized_keys file then is one line with two keys and does not work.

1 Reply

The linode-cli expects an "array of strings", so I can understand why you'd take the approach you did.

It's not the most intuitive thing, but to pass multiple SSH keys to separate lines in your authorized_keys file, you'll need to pass --athorized_keys multiple times. For example:

--authorized_keys 'ssh-key-1' --authorized_keys 'ssh-key-2'

The linode-cli will pick up from there and convert it to an array of strings, as you can see from this snippet from the --debug output:

"authorized_keys": ["ssh-key-1", "ssh-key-2"],

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct