If you are using Amazon EC2, and probably you have encountered the following situation:

ssh: connect to host [ip address] port 22: Connection refused

Normally, you would have nothing to do about it, since “having SSH connection” is your only way to get touch with the Amazon EC2 instance and its running system.

So, the question is: is there the only way to discard this EC2 instance?

Apparently, the answer is NO. We can work it around.

Root Reason

In the most cases, you haste this issue just because you have an extra EBS attached and not well set it up.

The issue was the error in /etc/fstab, and sshd was supposed to be started after fstab is successful.

However, if fstab cannot start up correctly, sshd will never get any chance to run. And this is the reason why you cannot SSH to the instance.


In order to get it fixed inside the fstab file to the “original Root EBS“, we have to find a way to get an access to it.

  • Set up a temporary instance, and mount the “Root EBS” from the original instance. Normally, this process needs you to “detach” the EBS from original instance and attach it to this temporary instance.
  • Get access to the fstab file in the “attached” EBS, and edit it as correct.
  • Put this “Root EBS” back to the original instance, and start it.

When editing the fstab file, the correct record for the attached EBS should be like:

/dev/xvdf       /ebs1   ext4    defaults        0       0

You can check here for more details about fstab.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>