Question

Add another ssh key on my droplet

Posted July 16, 2014 3.4k views

Hi all,

I can have two ssh key from different computer, right now I have one ssh key on my droplet, but I need another one ssh from my other computer.

I try this.

cat .ssh/id_rsa.pub | ssh root@dropletipaddress "cat >> ~/.ssh/authorized_keys"

but doesn’t work, but I not have password from my droplet, only connect with ssh.

as I can fix it.

thanks in advance.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

Hi!

What that command tries to do is take the contents of the file containing the public portion of your SSH key pair, ~/.ssh/id_rsa.pub and append it to the bottom of the file ~/.ssh/authorized_keys on your server.

So to add the new key, all you need to do is send the contents of ~/.ssh/id_rsa.pub to the computer that already has access to the server and then copy and paste it into the ~/.ssh/authorized_keys on the server.

If you are using Debian or Ubuntu and you have your public key on GitHub, you can use the ssh-import-id on the server to do this automatically. Run:

ssh-import-id gh:github_username
Submit an Answer