I created a user called grader to my instance and gave it sudo permission, also I switched the password in /etc/ssh/sshd_config to be off.

I generated a key pair in my local machine and added the public key to the instance. When I try to access the instance using the DEFAULT user provided by Amazon AWS and my generated keys it works

ssh -i "udacityLinux" ubuntu@ec2-18-218-9-117.us-east-2.compute.amazonaws.com

but when I try the same using the grader user I get this error:

ssh -i "udacityLinux" grader@ec2-18-218-9-117.us-east-2.compute.amazonaws.com
grader@ec2-18-218-9-117.us-east-2.compute.amazonaws.com: Permission denied (publickey).

How can I fix this to be able to login using my grader user?


1 Answer 1


You seem to have a misunderstanding about the public key you upload to the server.

This key must be stored in the file ~/.ssh/authorized_keys for every user that should be identified by this key.

This path ~/.ssh/authorized_keys is equivalent to your current user directory, if you are logged in as grader user, that path will point to:


In case you are logged in as ubuntu user, that path will point to:


So for now you could copy the key file with:

sudo cp /home/ubuntu/.ssh/authorized_keys /home/grader/.ssh/

Then set the correct owner and permissions:

sudo chown grader:grader /home/grader/.ssh/authorized_keys
sudo chmod 0600 /home/grader/.ssh/authorized_keys

Keep in mind that now you accept all keys that you might have enabled for the user ubuntu for the user grader as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.