Everything worked great till yesterday. Today I am unable to ssh
to my ec2
instance.
The settings are saved in .ssh/config
.
The error I get, when using test
username:
.us-east-2.compute.amazonaws.com: Permission denied (publickey).
I went ahead and double checked the permission on the .pem
file:
-r--------
I have another ec2
running with the same .pem
so I connected to it. No problem, login done.
I then tried to ssh
into the problematic ec2
with ubuntu
user and same .pem
file. It worked I was able to login.
I then switched users and the test
user exists.
I am not sure about what the issue might be.
Exited the ssh
session and tried connection again using the test
user and got the same error.
I found an answer here:
But the answer is not very helpful.
2
Answers
Abraam's answer is absolutely correct.
I am detailing the steps I followed to check and change the
authorized_keys
in remote i.e. theEC2
instance.ssh using the
ubuntu
user:see the entries in ubuntu
authorized_keys
:change user to
test
see the entries in test
authorized_keys
:if there is a difference and the key-pair is not present
Save and close the file.
ssh
should work now.It might be permission issue on the .ssh directory of the test user on the remote box