No ssh access after installing fail2ban and editing iptables

Hi there

I followed the steps here: https://library.linode.com/securing-your-server

in relation to installing fail2ban and changing my iptables config — I followed the steps in that article but have now lost ssh access to my linode.

I can get in via Lish but am unsure what to do next to restore access.

If I run sudo iptables -L -n , I get the following:

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
fail2ban-ssh  tcp  --  0.0.0.0/0            0.0.0.0/0            multiport dports 22
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           
REJECT     all  --  0.0.0.0/0            127.0.0.0/8          reject-with icmp-port-unreachable
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            state RELATED,ESTABLISHED
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:80
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:443
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:22
ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           
LOG        all  --  0.0.0.0/0            0.0.0.0/0            limit: avg 5/min burst 5 LOG flags 0 level 7 prefix "iptables denied: "
DROP       all  --  0.0.0.0/0            0.0.0.0/0           

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
DROP       all  --  0.0.0.0/0            0.0.0.0/0           

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           

Chain fail2ban-ssh (1 references)
target     prot opt source               destination         
RETURN     all  --  0.0.0.0/0            0.0.0.0/0          

And at this stage, /var/log/fail2ban.log only reveals:

2013-10-24 20:30:23,662 fail2ban.server : INFO   Changed logging target to /var/log/fail2ban.log for Fail2ban v0.8.6
2013-10-24 20:30:23,665 fail2ban.jail   : INFO   Creating new jail 'ssh'
2013-10-24 20:30:23,665 fail2ban.jail   : INFO   Jail 'ssh' uses poller
2013-10-24 20:30:23,747 fail2ban.filter : INFO   Added logfile = /var/log/auth.log
2013-10-24 20:30:23,752 fail2ban.filter : INFO   Set maxRetry = 6
2013-10-24 20:30:23,757 fail2ban.filter : INFO   Set findtime = 600
2013-10-24 20:30:23,760 fail2ban.actions: INFO   Set banTime = 600
2013-10-24 20:30:23,927 fail2ban.jail   : INFO   Jail 'ssh' started

Any clues on how to restore ssh access would be appreciated.

1 Reply

Ah, I just realised my issue. I'd changed the ssh port away from 22 to something more obscure and of course my iptables config above refers to port 22 — so problem solved.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct