Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

#useradd -m sample
#passwd sample
set password

#cat /etc/passwd
sample:x:508:1002::/home/monitor/sample:/bin/bash

# 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 superuser.com Dec 19 '11 at 23:00

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

add comment

1 Answer

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
add comment

Your Answer

 
discard

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.