I configured AWS EC2 ubuntu 12.04 instance and configured it as a web server. I successfully tested the webserver from my local maching using the Elastic IP.
While trying to install cpanel, there was a step which asked to disabled the firewall(CentOS in the tutorial), I searched the web and used the following command to disable it on Ubuntu
$ sudo ufw disable
Before a server restart, I re-enabled the firewall with eh command
$ sudo ufw enable
This command did showed me that it will change the behavior for the SSH connections. I agreed and pressed Y.
I restarted the server and when I tried to connect to the instance with the following command
$ sudo ssh -i key.pem [email protected]
It gave me this error
ssh: connect to host xx.xxx.xxx.xx port 22: Connection timed out
I tried to search the amazon FAQ page, but there was no ticket on this. Can anyone help me resolve this problem?
Today I ran into the exactly same situation. Here's how I fixed it in 3 easy steps :
Warning : Make sure your volumes are EBS, otherwise you will loose data in it.
Suppose INSTANCE-BROKEN is screwed up.
1.) PREPARE :
Create a new EC2 instance INSTANCE-FIXER.
IMPORTANT : This EC2 instance should be created in the same region (It was "us-west-1b" in my case) that has INSTANCE-BROKEN
Stop INSTANCE-BROKEN. Detach the volume from INSTANCE-BROKEN and attach the volume to INSTANCE-FIXER
2.) FIX :
Now start INSTANCE-FIXER and run fdisk to see what available volumes you have there :
sudo fdisk -l
Disk /dev/xvda1: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders, total 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/xvda1 doesn't contain a valid partition table
Disk /dev/xvdf: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders, total 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/xvdf doesn't contain a valid partition table
Mount the volume and edit this file as shown :
sudo mount /dev/xvdf /mnt
sudo vi /mnt/etc/ufw/ufw.conf
Edit and make sure ENABLED=no in the file.
unmount the device "/dev/xvdf" from INSTANCE-FIXER
detach the volume from INSTANCE-FIXER
3.) DONE :
Attach at "/dev/sda1" --- *IMPORTANT - ROOT device, otherwise your instance won't start
to the INSTANCE-BROKEN
Start the INSTANCE-BROKEN, now it should work; and
Terminate the INSTANCE-FIXER.
Now you can Login with SSH.
This happened to me as well. Luckily, I was working on 2 terminal windows, and I didn't get booted off one of the sessions. What I did is I allowed incoming traffic on the default ssh port(22). This worked for me:
sudo iptables -A INPUT -p tcp --dport ssh -j ACCEPT
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With