1

So I was ssh'd into my running instance while trying to set up Postfix for mailing.. I was fallowing this tutorial: http://flurdy.com/docs/postfix/#ec2. I got to the Shorewall part and fallowed all of the instructions. I think while I was doing that, I locked myself out of my SSH.

Currently I would like to remove the Shorewall firewall that is locking me out of the ssh. How could I do this?

Shorewall settings:

/etc/shorewall/interfaces
net     eth0            detect          dhcp,tcpflags,logmartians,nosmurfs

/etc/shorewall/zones
Add the firewall if not there and the internet as a zone.
fw  firewall
# loc   ipv4
net     ipv4

/etc/shorewall/hosts
# loc   eth0:192.168.0.0/24

/etc/shorewall/policy
$FW             net             ACCEPT
net             $FW             DROP            info
net             all             DROP            info
# The FOLLOWING POLICY MUST BE LAST
all             all             REJECT          info

/etc/shorewall/routestopped
eth0            0.0.0.0                 routeback

/etc/shorewall/rules
Ping/ACCEPT     net             $FW

# Permit all ICMP traffic FROM the firewall TO the net zone
ACCEPT          $FW             net             icmp

# mail lines
SMTP/ACCEPT     net             $FW
SMTPS/ACCEPT    net             $FW
Submission/ACCEPT       net             $FW
IMAP/ACCEPT     net             $FW
IMAPS/ACCEPT    net             $FW

#web
Web/ACCEPT      net             $FW
3
  • If you've blocked SSH on an EC2 instance it isn't going to be usable. If it had important data on it, you can get it by attaching the EBS volume to a new instance.
    – ceejayoz
    Oct 31, 2014 at 17:43
  • There has to be some way to access a running instance, or kill a running application on a server without ssh-ing into it.
    – Sari Rahal
    Oct 31, 2014 at 18:35
  • You're welcome to believe whatever you want, but there isn't. SSH is the only way in - if you stop it, or block all IPs via iptables, or something similar, you will not be able to get back in.
    – ceejayoz
    Oct 31, 2014 at 19:20

1 Answer 1

1

The correct way to fix this issue is to start a new instance and mount your old directory. After you mount the old directory with the new instance, you should be able to undo the firewall and remove it from the start up of the instance. Then restart your old instance and the fire wall will not start. Then ssh into it like normal.

Here is a nice tutorial on how to do it. https://aws.amazon.com/articles/5213606968661598

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .