Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
 Post subject:
PostPosted: Thu Sep 08, 2011 9:01 pm 
Offline
Senior Member

Joined: Mon Dec 07, 2009 6:46 am
Posts: 331
I like to move SSH to a higher port, and then use fail2ban to blast anything that touches port 22 for good 24 hours. Of course, any failed auth attempt to the real SSH port gets blasted too (using pubkey of course).


Top
   
 Post subject: sharing is caring
PostPosted: Fri Sep 09, 2011 12:18 pm 
Offline
Junior Member

Joined: Fri Jul 08, 2011 7:46 pm
Posts: 44
Website: http://ericsonwilkinson.me
Location: United States
Azathoth wrote:
I like to move SSH to a higher port, and then use fail2ban to blast anything that touches port 22 for good 24 hours. Of course, any failed auth attempt to the real SSH port gets blasted too (using pubkey of course).


Care to share your config options to accomplish that. Would save me a little google-fu :D


Top
   
 Post subject:
PostPosted: Fri Sep 09, 2011 5:28 pm 
Offline
Senior Member

Joined: Mon Dec 07, 2009 6:46 am
Posts: 331
Firewall (iptables):

Code:
...
iptables -A INPUT -p tcp --dport 22 -m state --state NEW -j LOG --log-prefix "iptables: DROP: "
iptables -A INPUT -p tcp --dport 22 -j DROP
...



fail2ban filter:
Code:
[Definition]
failregex = iptables: DROP: .* SRC=(?P<host>\S*) DST.*
ignoreregex =



fail2ban jail config:
Code:
[ssh-22]
enabled  = true
filter   = ssh-22
action   = iptables[name=SSH-22, port=22, protocol=tcp]
           sendmail-whois[name=SSH-22, dest=root]
logpath  = /var/log/iptables.log
maxretry = 1
bantime = 86400


What I'll probably do though is to put the iptables log at the end of teh valid input chain and not assigned to any port, so that I can ban anything that touches any port other than active enabled services. IMHO this should break any portscan attempt assuming they start at lower ports and work upwards.


Top
   
 Post subject:
PostPosted: Fri Sep 09, 2011 5:47 pm 
Offline
Senior Member

Joined: Sat May 03, 2008 4:01 pm
Posts: 569
Website: http://www.mattnordhoff.com/
If you're busy banning port scans, I hope you don't run an IRC client...

_________________
Matt Nordhoff (aka Peng on IRC)


Top
   
 Post subject:
PostPosted: Fri Sep 09, 2011 6:02 pm 
Offline
Junior Member

Joined: Fri Jul 08, 2011 7:46 pm
Posts: 44
Website: http://ericsonwilkinson.me
Location: United States
I don't run irc, but that reminds me I wanted to implement a web based chat at some point, thanks :)


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group