Adding second SSH key to droplet

April 23, 2014 3.7k views
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
1 comment
  • cat ~/.ssh/ | ssh root@<YOURIP> 'cat - >> ~/.ssh/authorized_keys'

7 Answers
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.

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.

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.
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.
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, 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 :(
I really appreciate you helping me so far though Andrew

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

I am having the same issue? Any ideas?

Have another answer? Share your knowledge.