Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a ubuntu Natty instance on EC2, and I can SSH into it by

ssh -v -i ec2-keypair

But I'd like to set up password less sshing. So I tried these options and nothing is working:

 $ ssh-copy-id -i ~/.ssh/
Permission denied (publickey).

 $ ssh-copy-id -i ~/.ssh/ec2-keypair
/usr/bin/ssh-copy-id: ERROR: No identities found

 $ ssh-copy-id -i ~/.ssh/
Permission denied (publickey).
share|improve this question
Remember to accept your own answer. – Daniel Beck Oct 9 '11 at 18:29
up vote 13 down vote accepted

I needed to run

ssh-add ~/.ssh/ec2-keypair
share|improve this answer
This works perfectly. Thanks! – Pavel Nikolov Jan 11 '13 at 14:37

I had the same problem: ssh-copy-id gives the error Permission denied (publickey) on an AWS EC2 instance. I was sure that I set all the permissions correctly using chmod.

In addition, I needed to change this line in /etc/ssh/sshd_config from

PasswordAuthentication no


PasswordAuthentication yes

I guess that's because ssh-copy-id asks for your password.

Then the error disappeared.

share|improve this answer
Beware though that changing the PasswordAuthentication from 'no' to 'yes' can lock you out of your EC2 instance. – Kingz Jul 8 '14 at 23:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .