Server Fault is a question and answer site for system and network administrators. 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

How to login with non ec2-user account in amazon linux ami?

#useradd -m sample
#passwd sample
set password

#cat /etc/passwd

# cat /home/monitor/sample/.ssh/authorized_keys
command="echo 'Please login as the ec2-user user rather than root
user.';echo;sleep10"    ssh-rsa xxxxxxxxx

# chown -R sample /home/monitor/sample/.ssh

I copied /root/.ssh/authorized_keys to the new user's .ssh directory also

At login time server says 'server refused our key' and no supported authentication method available popup.

How to associate sample with my existing key pair?

share|improve this question

migrated from Dec 19 '11 at 23:00

This question came from our site for computer enthusiasts and power users.

up vote 3 down vote accepted

Instead of copying /root/.ssh/authorized_keys you should be copying /home/ec2-user/.ssh/authorized_keys to the new user's authorized_keys file. You'll also want to make sure the permissions are set correctly.

For example:

rsync -a /home/ec2-user/.ssh /home/monitor/sample/
chown -R sample:sample /home/monitor/.ssh
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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