How can I recover SSH access to a amazon EC2 instance after UFW firewall activation by accident?

amazon-ec2, ssh, ubuntu-12.04

Solution

Well, thanks to EBS there is a solution.

- Stop your instance

- Attach your EBS volume to another instance. if you don't have one, create a micro instance.

- Mount yor EBS volume somewhere ie. /opt/recover

- List item

- Edit {your-ebs-mount}/etc/ufw/ufw.conf and change enabled=yes to enabled=no

- Umount the EBS

- Detach from the temp instance

- Reattach to the original instance. (make sure to attach as root)

- Restart the instance

Now you firewall is disbled in your instance, so you can access it via ssh.

Problem

I have activated UFW firewall in an EC2 ubuntu server 12.04 instance, but I forgot to allow access to port 22. Now I can't connect to the instance via SSH. This instance is EBS backed. How can I recover SSH access to a amazon EC2 instance after UFW firewall activation by accident?

Original source