linode-cli icon indicating copy to clipboard operation
linode-cli copied to clipboard

Rebuild command fails when passing an authorized_keys

Open dkam opened this issue 4 years ago • 3 comments

Rebuilding a host fails with incorrect error message

$ linode-cli linodes rebuild 1234 --root_pass somepassword --authorized_keys ~/.ssh/id_ed25519.pub
Request failed: 400
┌errors───────────┬────────────────────────────────────────────────────────────────────────────────┐
│ field           │ reason                                                                         │
├─────────────────┼────────────────────────────────────────────────────────────────────────────────┤
│ authorized_keys │ SSH Key 1 key-type must be ssh-dss, ssh-rsa, ecdsa-sha2-nistp, or ssh-ed25519. │
└─────────────────┴────────────────────────────────────────────────────────────────────────────────┘

The key used is ed25519 and is the same key in my Linode profile.

The command also fails if I pass in the key id retrieved from linode-cli sshkeys list

$ linode-cli linodes rebuild 123 --root_pass somepassword --authorized_keys 1234
Request failed: 400
┌errors───────────┬────────────────────────────────────────────────────────────────────────────────┐
│ field           │ reason                                                                         │
├─────────────────┼────────────────────────────────────────────────────────────────────────────────┤
│ authorized_keys │ SSH Key 1 key-type must be ssh-dss, ssh-rsa, ecdsa-sha2-nistp, or ssh-ed25519. │
└─────────────────┴────────────────────────────────────────────────────────────────────────────────┘

dkam avatar Nov 15 '19 06:11 dkam

Ohhh - you actually have to pass in the value of the key, but not the comment like
--authorized_keys ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINabcde

Not:

--authorized_keys `cat ~/.ssh/id_ed25519.pub`

Maybe authorized_keys should test if the argument is a file? Alternatively, perhaps it should accept the comment in an ssh file?

dkam avatar Nov 15 '19 06:11 dkam

I like the idea of looking for a file if the input looks like a path. What comment do you have in your public key that it isn't accepting?

Dorthu avatar Nov 15 '19 12:11 Dorthu

Actually, it was a matter of quoting - this works:

--authorized_keys "`cat ~/.ssh/id_ed25519.pub`"

or

--authorized_keys "$(cat ~/.ssh/id_ed25519.pub)"

dkam avatar Nov 15 '19 12:11 dkam

Closing this issue as it seems to be resolved. Feel free to @ me if this issue is still relevant.

lgarber-akamai avatar Oct 24 '22 13:10 lgarber-akamai