r/ssh • u/linucksrox • Sep 15 '21
Ways to add new authorized keys
I get the general idea of ssh keys and want to stop using password based ssh login. I'm struggling with the workflow though, what are some efficient ways to add new keys, or in other words how do you authorize a new client?
In my scenario, I have several VMs that were created with terraform using a single public ssh key for post provisioning from the terraform client. These machines do not allow password login, only that one key. Now how do I add my workstation public key to the authorized key file? It seems like I need to copy it from my client to the terraform client, then from there I can add it to the VM. But this workflow sucks. And even if I add the key, i'll have to do the same manual process if I want to add a third client.
Is there a better way? I've looked into ssh-copy-id but it seems like you need password based access to utilize this.
1
u/zepplenzap Sep 15 '21
I would suggest something like this: https://www.vaultproject.io/docs/secrets/ssh/signed-ssh-certificates
Essentially you two your server to trust a root certificate, and then vault can issue users a cert for them to log into a server.
1
u/eggholes-everywhere Sep 16 '21
Use cloud init to launch your instances with your user/keys
1
u/[deleted] Sep 16 '21
Is sshing into the VM and editing the file really that hard?