Adding second SSH key to droplet

  • Posted April 23, 2014

Ok here goes, my team member set up ssh login to our server on his computer; now I’d like to be able to access the server via my shell and I would like to be able to SSH in. The problem I am having is that I cannot seem to find a way to add my public key to the “authorized_keys” file on the server; when I try to login and run the “cat ~/.ssh/ | ssh ‘cat - >> ~/.ssh/authorized_keys’” from my local terminal i am prompted to enter a password; which i then enter the root pw which DO sent us but it consistently gives me a “permission denied” result; alternatively when I login to the server using DO’s console access page and try to run “cat >>~/.ssh/authorized_keys” it says “no such file or directory:” I’m a total beginner if you can’t tell so any help or guidance would be greatly appreciated


cat ~/.ssh/ | ssh root@<YOUR_IP> ‘cat - >> ~/.ssh/authorized_keys’

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

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.

I am having the same issue? Any ideas?

This comment has been deleted

I’m having the exact same issue. Not sure exactly why. Any clue on how to solve this?

Well, i manually added my ssh key to the authorized users and I ran a sudo reboot from the DO console to restart the server- but yea when I try to ssh in from my local shell i still get prompted to enter a password that i do not have :(
<br>I really appreciate you helping me so far though Andrew

You can open the file and edit it with “nano ~/.ssh/authorized_keys” and type it in manually if you want. That will be a bit of a pain as it is a long random string, but you can do it.

Well the thing is I have access to the server using Digital oceans console access page; what command would I run to add it from there? would it simply be… “cat (contents of >> ~/.ssh/authorized_keys” ; I can see that this will probably be difficult to do as i cannot paste into the DO console so i’d have to type out all of the contents of… thanks so much for the fast initial response.

Did your colleague disable ssh password log-in? That’s a normal step when hardening a server. It only allows users to login via ssh using their keys for authentication. That would explain why the first command doesn’t work. <br> <br>The file “” is the public half of the ssh key pair that you created. It is on your local machine. Essentially what you are trying to do is take the contents of that file on your local machine and append it to the bottom of the file “~/.ssh/authorized_keys” on the remote server. <br> <br>You do not need to keep its contents of the public key secret. You should give it to the team member with access to the server, and they should add it to the bottom of the authorized_keys keys file.