Question

Add another ssh key on my droplet

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.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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