The hard drive on my development server was failing last week so I had the fun job of getting the data off of it while I was still able to. The process of getting all my data and installing Ubuntu 8.04.2 LTS on my new hard drive took the better part of two days. After getting the server back to a solid state from which to build my LAMP stack on, I decided it would be a good idea to follow standard security procedures and install fail2ban to block any unintelligent hackers. I think any hackers worth their respective salt can get around a basic implementation of fail2ban, but this is just my dev server and I don’t have any sensitive data on it, so I’m not too worried.
Today I was toiling away on my company’s website, updating, fixing, etc… I was attempting to upload ~7 MB, 1312 files onto the server and my ftp client, filezilla, crashed. I figured it was a one-time crash, so I reloaded filezilla and tried again, crash again. I tried one more time just to make sure I was doing everything correctly. Crash again. I believe the issue revolved around the number of files I was transferring at once, so I tarballed the files and pulled filezilla back up and….couldn’t log into the server with filezilla. After a moment of troubleshooting I realized I couldn’t log into the server via filezilla or putty (I sftp through port 22). I was able to login, with my same username/password through putty AND filezilla through the public ip address though.
After digging through the log files and ifconfig to make sure my server wasn’t dying again I pulled up my iptables. Yep, I was banned. Apparently when filezilla was crashing there was some sort of login attempt made to the dev server and each login attempt failed. So after my three attempts to upload my files, I was banned. Lesson learned, always have two access methods to any server. It makes troubleshooting issues much easier.
BTW, for reference the commands for iptables is:
list all banned ip’s
iptables -L -n -v Chain INPUT (policy ACCEPT 78238 packets, 18M bytes) pkts bytes target prot opt in out source destination Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 83695 packets, 66M bytes) pkts bytes target prot opt in out source destination Chain fail2ban-ssh (0 references) pkts bytes target prot opt in out source destination 36 3456 DROP all -- * * 10.0.55.4 0.0.0.0/0 22 1732 DROP all -- * * 81.208.51.90 0.0.0.0/0 41764 7846K RETURN all -- * * 0.0.0.0/0 0.0.0.0/0
list all banned ip’s for a specific program (fail2ban-ssh) with line numbers
iptables -L fail2ban-ssh -n -v --line-numbers Chain fail2ban-ssh (0 references) num pkts bytes target prot opt in out source destination 1 36 3456 DROP all -- * * 10.0.55.4 0.0.0.0/0 2 22 1732 DROP all -- * * 81.208.51.90 0.0.0.0/0 3 41764 7846K RETURN all -- * * 0.0.0.0/0 0.0.0.0/0
remove banned ip from iptables
iptables -D fail2ban-ssh 1[line-number]
Till Next Time