2

I've tried looking in the forums before posting this but can't find anything that really addresses my issue. Very simply, my problem is in the topic: I created a new user, afterwards, I can login with the new user, but when I try to use login as ec2-user, I get a message from the instance stating, "The client has disconnected from the server. Reason: Unable to authenticate using any of the configured authentication methods."

I've been using the .pem file I got since I created this instance, which is Amazon Linux AMI. When I created the new user, I essentially used this guide, but for completeness (since I know the devil is in the details), I can list everything that I typed.

sudo adduser exampleuser  
sudo su exampleuser  
mkdir .ssh (made sure I was in home dir of exampleuser)  
chmod 700 .ssh  
touch authorized_keys  
chmod 600 authorized_keys  
su  
usermod -a -G ec2-user exampleuser  
ssh-keygen -t rsa <asked me what filename to save as, I put exampleuser.pub>  
cat exampleuser.pub >> ~/.ssh/authorized_keys  
chgrp ec2-user /home/ec2-user  
chmod g+rwx /home/ec2-user  

Now, what probably screwed this up is that there is a program in the ec2-user home directory that the new user(s) will need to have access to, so I added them to the ec2-user group. I've looked in /etc/group and I see ec2-user is a member of "wheel" and exampleuser is a member of "ec2-user" as well as group "exampleuser", however when I type "groups ec2-user" it gives output of:

ec2-user: ec2-user wheel

while "groups exampleuser" gives output of:

exampleuser: exampleuser ec2-user

One thing I did have the presence of mind to do is create a root user (or set a root password), so I can become root on this system, hopefully this will allow me to fix things? I went back and looked at /home/ec2-user and saw that the .ssh directory had the wrong permissions so I did "su -l ec2-user" and redid "chmod 700 .ssh" as well as "chmod 600 authorized_keys", but it didn't make any difference. I also compared the public key in authorized_keys in the /home/ec2-user with the output from PuttyGen on my .pem file and it matches. Please tell me what I'm missing to allow me to log back in with the .pem file as ec2-user?

If there's more information that's required, please let me know and thank you. I hope that this is in the right place, my apologies if it isn't.

0

I found the solution to this, it was that the permissions on the ec2-user directory were 774 instead of 744. Changing this allowed me to be able to log back in with the ec2-user. Hopefully, this will help somebody else out there.

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.