Search code examples
amazon-web-servicessshamazon-ec2connectionfilezilla

Can't ssh or sftp into ec2 instance


I have seen quite some posts about my problem, but none is exactly my case. I have an Ec2 ubuntu instance that I have been working on for some time now. I never had to do anything special to connect using ssh of filezilla. I just had my key, with the right permissions and that was it. Suddenly, today, while i was using filezilla to do some stuff, i got an error.

Error:  Disconnected: No supported authentication methods available (server sent: publickey)
Error:  Could not connect to server

At the same time, i was connected in the ssh (mac terminal), and didn't think it was something special, so i tried to disconnect and reconnect in the terminal.

I got Permission denied (publickey)...

I don't know what i changed, if i ever changed anything, and I am far from a linux/aws expert.

Anyways, I am getting pretty scared right now, because I had setup some good crawlers that i don't have a recent backup for.

I tried creating an AMI, hoping to clone the server and be able to access it again as another instance, but when i created the other instance and tried to connect with the other key, I got the same thing.

What should I do ?..


Solution

  • You might have changed some permissions. Now the only option is create another instance. Stop the current instance and detach volume and attach to newly created instance. SSH into new instance and mount the attached volume. Now correct the permission on old instance and unmount the volume. Stop the instance and detach the volume and attach it back to previous instance. Start the old instance and try to ssh. If the permissions are corrected you should able to log in again.