[Suggestion] Support setting default SSH key(s) to be automatically used during creation
I've looked around the README, --help, the issue tracker, and tried just searching "linode-cli default ssh key", but it doesn't appear to be a supported feature.
Currently, it's a pain to use an SSH key with linode-cli, because you need to specify the raw key on the command line like so:
linode-cli linodes create --label test --root_pass 'Hello@World' --authorized_keys 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIdnuvAH4SPWcf8iV5Oj7psh6jKFbN9NH+tcdGYSEfma john@johndoe'
It would be great if it was possible to have one or more default SSH keys that would be automatically used during create and other commands that accept SSH keys, similar to how you can already select a default region, linode package, and operating system to use.
For example, in ~/.config/linode-cli you could specify an SSH public key directly in a config key:
[DEFAULT]
default-user = johndoe
[johndoe]
token = abcd1234abcd1234
region = eu-central
type = g6-standard-1
image = linode/ubuntu20.04
sshkey = ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIdnuvAH4SPWcf8iV5Oj7psh6jKFbN9NH+tcdGYSEfma john@johndoe
For multiple SSH keys, you could specify sshkey multiple times
sshkey = ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIdnuvAH4SPWcf8iV5Oj7psh6jKFbN9NH+tcdGYSEfma john@johndoe
sshkey = ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKSbBdu7wunXL3nlsRrEh6aVsnOfykgCj+GAmnRTPXjs john@iPad
Additionally or alternatively, it might be easier to use saved keys on your Linode account
# Use both of the SSH keys "johndoe" and "iPad" saved on the Linode account
sshkey = johndoe iPad
And/or even read them from a file:
sshkey = ~/.ssh/id_ed25519.pub
sshkey = ~/.ssh/id_rsa.pub
sshkey = /opt/keys/ipad.pub
This is a great idea!
Right now there are a few other ways to set an ssh key. You can cat the key from a file in your shell:
linode-cli linodes create --root_pass --authorized_keys "$(cat ~/.ssh/id_rsa.pub)"
You can also attach your public key to your user account and then deploy with it there:
linode-cli sshkeys create --label laptop-key --ssh_key "$(cat ~/.ssh/id_rsa.pub)"
linode-cli linodes create --root_pass --authorized_users $MY_USERNAME
(note that if you use --authorized_users, all keys that you attached to your Linode account will be installed for the root user).
I'm going to discuss this with the team internally and see how they feel about it, but I do agree that it should be easier to provision Linodes with ssh keys.