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?
You copied the root keys, and not the ec2-user keys. You should copy those keys and then ensure you’ve set the proper permissions.
If this doesn’t fix the problem, run a verbose ssh connection, and paste the results (removing any pertinent info)
and I’ll try to help more.