Page 1 of 1

Connection issues

Posted: 2019/09/25 16:29:27
by afernandezody
Hello,
I'm running into a weird problem when creating user accounts and connecting to AWS instances. The process involves starting two instances, one with CentOS and the other with AmazonLinux2, and creating another user (the full steps are described at https://docs.aws.amazon.com/AWSEC2/late ... users.html) with the commands:

Code: Select all

sudo adduser monica
sudo su - monica
mkdir .ssh
chmod 700 .ssh
touch .ssh/authorized_keys
vi .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
Nothing out of ordinary. However, and when I try to connect to the instance as the new user (e.g. 'monica'), the ssh connection works seamlessly for the AmazonLinux2 instance but doesn't work for the CentOS instance. The error message is the well-known:

Code: Select all

login as: monica
Server refused our key
I'm trying to figure out why of the different response and the root of the problem for CentOS. Any suggestion would be greatly appreciated.
Thank you,
Arturo

Re: Connection issues

Posted: 2019/09/25 20:51:09
by TrevorH
Try restorecon -RFv $USER/.ssh

Re: Connection issues

Posted: 2019/09/25 21:25:11
by afernandezody
Hi @TrevorH,
Thanks. It didn't work, it's still refusing the connection. The putty window is outputting: Disconnected: No supported authentication methods available (server sent: publickey,gssapi-keyex,gssapi-with-mic).

Re: Connection issues

Posted: 2019/09/25 21:27:19
by TrevorH
Then you need to read /var/log/secure on the server to find out why it's doing this.

Re: Connection issues

Posted: 2019/09/25 22:58:45
by afernandezody
I still cannot figure out why it's failing in one OS but not in the other. The secure file in CentOS is not providing any specifics:

Code: Select all

Sep 25 22:23:15 ip-172-31-22-38 sshd[1685]: error: Received disconnect from 73.214.236.221 port 51253:14: No supported authentication methods available [preauth]
Sep 25 22:23:15 ip-172-31-22-38 sshd[1685]: Disconnected from 73.214.236.221 port 51253 [preauth]
However, the same procedure works in ALinux2:

Code: Select all

Sep 25 22:50:58 ip-172-31-23-183 sshd[3535]: Accepted publickey for monica from 73.214.236.221 port 51852 ssh2: RSA SHA256:2k9zgOzGS5N1t661sTesoF0xpRDTCC7O/M7wI5mZlXg
Sep 25 22:50:58 ip-172-31-23-183 sshd[3535]: pam_unix(sshd:session): session opened for user monica by (uid=0)
The only noticeable difference is the port (51253 vs. 51852) but I wouldn't think that to cause the failure.

Re: Connection issues

Posted: 2019/09/26 13:23:57
by stevemowbray
Look for diferences between the sshd configs (/etc/ssh/sshd_config) on the two instances.

Re: Connection issues

Posted: 2019/09/26 13:47:16
by afernandezody
Hi @stevemowbray,
Thanks for your answer. The files are quite different! The CentOS one is warning me that it was created with Chef and shouldn't be modified manually. Before testing any changes, I'll have to study up on this config file as I'm unfamiliar with its syntax & parameters.