0

I can't ssh to my server on AWS ec2 after I made chmod to home directory of the server(I can't remember exact command I made to the home directory).

When I tried to ssh to my server, I got message like below.

...
Host '????' is known and matches the ECDSA host key.
...
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
...

What should I do?

2
  • Was it working earlier, before chmod to home dir? Jul 9, 2020 at 8:56
  • It would help if we knew the exact command, as ssh is kind of picky about the permissions of its files. If, for example, you have given write access to everyone on the authorized_keys file, ssh will refuse to use the file, making login to the server by keyfile impossible.
    – Lacek
    Jul 9, 2020 at 9:01

3 Answers 3

1

ssh requires the user used to login to server to have access to /home/username/.ssh. If you can't access the server with another user you can

  • stop the instance
  • launch a new instance with the EBS from the server attached to it
  • login to the new server and adjust the permissions for on the EBS

Consult this Q&A for the permissions you should have for the .ssh folder.

0

AWS stores EC2 private keys in the /home/.ssh directory and you get the public key for that.
Now looks like you have removed access to /home dir, hence you are not even able to login into. Now there are two ways to fix this:

  1. UI console for EC2 server -which AWS doesn't provide, I guess.
  2. Try ssh from another EC2 server within the same network and region and correct the /home dir permissions.
-1

Thank you for all the answers and comments. And I want to share the link(https://aws.amazon.com/premiumsupport/knowledge-center/ec2-linux-fix-permission-denied-errors/). The method3 was worked well for me.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .