dermd
dermd

Reputation: 167

Sudden error SSHing into EC2 instance

I've been using an ec2 instance for a couple of weeks with no issues. Out of nowhere today the instance would no longer let me login with my private. I get

Server refused our key

Disconnected: No supported authentication methods available (server sent: publickey)

I can't figure out why this started happening out of nowhere today. I tried rebooting the instance but no luck so I imaged the instance and launched a new instance from the image with a fresh key pair. I'm getting the same error when logging into this new instance with the new private key.

I'm using a basic security group which is open

22 (SSH) 0.0.0.0/0

80 (HTTP) 0.0.0.0/0

443 (HTTPS) 0.0.0.0/0

8080 (HTTP*) 0.0.0.0/0

Anyone come across this before or have any ideas what I'm doing wrong?

Thanks, Derm

Upvotes: 2

Views: 296

Answers (1)

dermd
dermd

Reputation: 167

After a bit of messing around I figured out the issue. In case anyone comes across a similar issue… Running a custom script I accidentally messed up the permissions on the ec2-user home directory which locked the ec2-user out of the server.

To fix it I detached the root volume from the instance (using the CLI ec2-detach-volume) and attached it to another temp instance (using the CLI ec2-attach-volume), mounting it in a temp folder and changing the permissions on the ec2-user directory to og-rwx.

I then detached the volume from the temp instance and re-attached it as root to the original instance and was able to ssh in again with my original key.

Upvotes: 2

Related Questions