I have a Linux AMI setup on EC2. The default user is ec2-user. I created a second user account on the instance. I copied the .ssh/authorized_keys file from ec2-user home directory to the new user's home directory. Set the privs on .ssh/ to 700 and on authorized_keys to 600. Executed 'chown' to set owner of the .ssh/ folder as the new user. But when I log in as the new user, I get a 'Permission denied (publickey).' message. Here is what I see when I run ssh -v -i:

debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: testami-key.pem
debug1: read PEM private key done: type RSA
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).

How do I fix this? Thanks.


1 Answer 1


Did you also chown the authorized_keys file to the new user name? You only mentioned chowning the .ssh directory.

  • Thank you! Thank you! Was struggling with this for several hours. Will accept answer when SO limitation expires.
    – sotn
    Jan 8, 2013 at 23:31

You must log in to answer this question.

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