Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EC2 SSH port 22 connection refused even though previously worked

I have an EC2 instance which i've got a couple of sites hosted on and it's previously been workin really nice.

Today I try to SSH into it and it just refusing connections on port 22 even though the security group has it open and the security group is set to the instance.

Anyone help me out as to why this could be the case?

I just get this line each time - ssh: connect to host 54.247.99.86 port 22: Connection refused

like image 474
David Avatar asked Sep 16 '12 13:09

David


People also ask

Why is my EC2 instance refused to connect?

The following are common causes for this error: The host reached the instance but there was no service listening on the SSH port. A firewall blocked and was set to reject the package instead of dropping it.

How do I fix SSH connected to host port 22 connection timed out?

Ensure that you are attempting to connect to the right port number for your server. Blocks due to firewall intervention – Some servers may be protected by firewalls at various points. If you are using a firewall, ensure that it isn't blocking access to your SSH port.

Why can I not SSH into my EC2 instance?

This error occurs if you created a password for your key file, but haven't manually entered the password. To resolve this error, enter the password or use ssh-agent to load the key automatically. There are a number of reasons why you might get an SSH error, like Resource temporarily unavailable.


1 Answers

If your instance is EBS based and not an Instance store then take an ami image first as a backup, then stop the instance, boot a new raw instance.

As your old instance is EBS based, detach the volume and attach it to new instance. Once attached mount it to some directory, change the permission /var/empty/sshd, also do cat /etc/fstab to know where was your / partition mounted. Now umount the volume from new instance attach to the old instance with the exact mount point which you had when in fstab like /dev/sda1 for /.

Once attached, start the old instance and check whether you are able to login or not.

like image 184
Jyotir Bhandari Avatar answered Sep 28 '22 00:09

Jyotir Bhandari