Iptables locking me out of SSH

128 views Asked by At

I was in a SSH server and ran the command

iptables -F

and the server froze.

Since then I just can't login back again.

After some research I found that that command can freeze if you are in a SSH server.

The question is. How can I "revert" this?

Can anyone help me?

1

There are 1 answers

0
Toby Speight On BEST ANSWER

If the remote server has ssh running over IPv6, you may be able to reconnect and load some more appropriate IPTables rules (as you've probably only dropped the IPv4 rules).

If there's no IPv6 or other non-IPv4 access (dial-up terminal server, IPMI console, etc), then you're out of luck, until you (or someone acting for you) get physical access. Assuming a default-deny policy (which seems to be the case based on what we see), you've completely isolated its IP interfaces.

Moral of the story: before meddling, save a copy of a working ruleset, and create an at or cron job to restore from that at a known time, in case it all goes wrong. I know that's too late to help now, but might save somebody else!