Add another ssh key on my droplet

July 16, 2014 3.3k 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/ | 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.

1 Answer


What that command tries to do is take the contents of the file containing the public portion of your SSH key pair, ~/.ssh/ 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/ 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
Have another answer? Share your knowledge.