Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
 Post subject: Fail2ban issue
PostPosted: Sun Aug 04, 2013 10:49 am 
Offline
Senior Member

Joined: Thu Jun 13, 2013 7:32 am
Posts: 79
Logwatch email mentioned this:

Code:
pam_unix
sshd:
  Authentication Failures:
     root (185.9.159.140): 480 Time(s)
     root (219.235.126.174): 35 Time(s)
  Invalid Users:
     Unknown Account: 3 Time(s)


With fail2ban, should 480 failures ever happen? Should 35 failures even happen?


Top
   
 Post subject: Re: Fail2ban issue
PostPosted: Sun Aug 04, 2013 11:28 am 
Offline
Senior Member
User avatar

Joined: Thu Jun 16, 2011 8:24 am
Posts: 412
Location: Cyberspace
Doesn't surprise me. Those are probably automated brute-force attacks -- in other words, people from those two IP addresses have their computers in auto-pilot trying to guess your root password. That sort of thing happens all the time, and they usually target any machine they can find which exposes ssh to the public.

One thing you can do is change the port ssh runs on. Since most attackers normally expect ssh on port 22, and since many are too lazy to run nmap (or similar) to identify what services are actually running on your open ports, that will greatly reduce log spam. You can even set it to something like 8080, which many corporate/institutional firewalls allow (it's a common alternate port for web browsing), and use as a means of proxying stuff that you need that may be blocked (careful doing that! many places will take issue).

You might want to see if you can do an rDNS lookup (Google can help you find a lookup service). The reason being that those IP addresses could belong to legitimate networks that got hacked. If they appear legit, it wouldn't hurt sending them an email to alert them so they can deal with it accordingly.

_________________
Kris the Piki Geeker


Top
   
 Post subject: Re: Fail2ban issue
PostPosted: Sun Aug 04, 2013 12:10 pm 
Offline
Junior Member

Joined: Sat Nov 03, 2007 11:33 am
Posts: 32
jgjh151 wrote:
Logwatch email mentioned this:

Code:
pam_unix
sshd:
  Authentication Failures:
     root (185.9.159.140): 480 Time(s)
     root (219.235.126.174): 35 Time(s)
  Invalid Users:
     Unknown Account: 3 Time(s)


With fail2ban, should 480 failures ever happen? Should 35 failures even happen?


Perhaps the attempts were spread out through the day? I'm not sure how the fail2ban threshold is set, but OSSEC will recognize and block those attacks after a few attempts. If the IP is the same, the repeat offenders option will add to the block time if they come back.


Last edited by mstarks01 on Sun Aug 04, 2013 1:57 pm, edited 1 time in total.

Top
   
 Post subject: Re: Fail2ban issue
PostPosted: Sun Aug 04, 2013 1:23 pm 
Offline
Senior Member
User avatar

Joined: Wed Mar 17, 2004 4:11 pm
Posts: 554
Website: http://www.unixtastic.com
Location: Europe
Sednet's often repeated turbo guide to SSH:

Setup SSH to use keypairs and disable all password authentication. Then you are immune to password guessing attempts. The only time you should use password authentication on an Internet connected machine is as a second authentication method should you use OpenSSH 6.2 double authentication. Most likely you will never do that.

Setup verbose logging so you log the key fingerprint of connections.

Enable privilege separation.

Disable everything you don't use, like kerberos and host based authentication.

Every so often check your authorized_keys files only contain correct and current keys.

Force keys to a source IP if practical.

Use forced commands with keys if practical.

Disable tunneling and X forwarding on keys where this isn't needed.

Moving the SSH port will reduce log spam but it has no security implications.

Use a strong passphrase and change your keypair if there is any doubt about it being leaked.

If you want to rate limit SSH connections do it with iptables. Kernel level network filtering has far lower overhead than fail2ban and is less likely to go wrong. Fail2ban might make some sense if it's protecting a web framework with suspected security issues but it really doesn't make much sense protecting an uberparanoid service like SSH.


Top
   
 Post subject: Re: Fail2ban issue
PostPosted: Sun Aug 04, 2013 1:53 pm 
Offline
Senior Member
User avatar

Joined: Sun Dec 27, 2009 11:12 pm
Posts: 1038
Location: Colorado, USA
What Sednet said.

Plus, the best way (along with only accepting certs instead of passwords) is to use IPTABLES and ONLY allow trusted IP's to connect to your not-TCP22 SSH port.

But....but...Skippy - what if I'm skiing on the Alps or surfing Big Sur and a clients site goes down?

Really? How often has that happened? How often will it? Besides, how often will your random IP based smart phone be able to save the day? If you just have to have that type of connection - then setup a VPN to YOUR home base, and then vpn into your system which can then SSH into your protected hosts. If you really need secure anywhere access to your public hosts - don't use SSH use a VPN.

_________________
Either provide enough details for people to help, or sit back and listen to the crickets chirp.
Security thru obscurity is a myth - and really really annoying.


Top
   
 Post subject: Re: Fail2ban issue
PostPosted: Sun Aug 04, 2013 3:06 pm 
Offline
Senior Member
User avatar

Joined: Wed Mar 17, 2004 4:11 pm
Posts: 554
Website: http://www.unixtastic.com
Location: Europe
vonskippy wrote:
But....but...Skippy - what if I'm skiing on the Alps or surfing Big Sur and a clients site goes down?

Really? How often has that happened?


It's happened plenty to me.

There was that time I was happily eating soft shell crab in a restaurant in Hong Kong. So what do management do? Ruin my day by calling me instead of engaging their brains and solving a dead simple issue themselves.

Or that time I was having my birthday dinner at the best restaurant in town and got the call because the active directory servers went down. All of them. Hundreds worldwide.

Or that time I was paged every 10 minutes all night with blank messages, then got moaned at the next day because I didn't fix something nobody told me about.


If you are personally expected to look after some systems it's always worth having some way into them with you. Smartphones work great but laptops are easier for serious typing. Bouncing connections though another system is fine as long as it's tested before you need it.


Top
   
 Post subject: Re: Fail2ban issue
PostPosted: Sun Aug 04, 2013 8:38 pm 
Offline
Senior Member

Joined: Thu Jun 13, 2013 7:32 am
Posts: 79
Thanks everyone. Password authentication has been disabled. Now I have to look into implementing some of these tips.


Top
   
 Post subject: Re: Fail2ban issue
PostPosted: Sun Aug 04, 2013 8:56 pm 
Offline
Senior Member
User avatar

Joined: Thu Jun 16, 2011 8:24 am
Posts: 412
Location: Cyberspace
X forwarding and the ssh port are set in the same sshd_config you used to disable password authentication. Some distros include a command call chkconfig that you can use to disable services at boot time (though you'll still need to stop them manually if you don't want to reboot).

As for the other tips, those more experienced than me will need to help.

_________________
Kris the Piki Geeker


Top
   
 Post subject: Re: Fail2ban issue
PostPosted: Thu Aug 08, 2013 6:36 am 
Offline
Senior Member

Joined: Thu Jun 13, 2013 7:32 am
Posts: 79
Logwatch has this today. If fail2bam is working, this should not be happening right?
Quote:
SSHD
Illegal users from:
undef: 750 times
190.82.84.203 (mail.elmostrador.cl): 747 times


Top
   
 Post subject: Re: Fail2ban issue
PostPosted: Thu Aug 08, 2013 9:54 am 
Offline
Senior Member

Joined: Thu Jun 13, 2013 7:32 am
Posts: 79
I put in a rate limit of 3 connecitons per minute in iptables to avoid this...I'll check logs tomorrow.


Top
   
 Post subject: Re: Fail2ban issue
PostPosted: Fri Aug 09, 2013 6:30 am 
Offline
Senior Member

Joined: Thu Jun 13, 2013 7:32 am
Posts: 79
Still seeing this even with fail2ban and iptables rate limiting:

Code:

SSHD

Illegal users from:
  undef: 215 times
  61.155.177.58: 190 times




and

Code:
SSHD

Received disconnect:
  11: Bye Bye [preauth] : 704 Time(s)



Top
   
 Post subject: Re: Fail2ban issue
PostPosted: Fri Aug 09, 2013 7:06 am 
Offline
Senior Member
User avatar

Joined: Sat Aug 30, 2008 1:55 pm
Posts: 1739
Location: Rochester, New York
What do your actual logs say? logwatch eliminates the vast majority of useful information.

_________________
Code:
/* TODO: need to add signature to posts */


Top
   
 Post subject: Re: Fail2ban issue
PostPosted: Fri Aug 09, 2013 10:13 pm 
Offline

Joined: Tue Nov 04, 2003 1:00 am
Posts: 1
jgjh151 wrote:
Still seeing this even with fail2ban and iptables rate limiting:

SSHD

Received disconnect:
11: Bye Bye [preauth] : 704 Time(s)


Did you start fail2ban? Are you getting any log entries in /var/log/fail2ban? The linode instructions don't mention starting up the service, but it needs doing. There's presumably a right way to start it, but I just rebooted and that knocked down the many hundreds of login attempts per day to almost nothing.


Top
   
 Post subject: Re: Fail2ban issue
PostPosted: Sat Aug 10, 2013 10:15 am 
Offline
Senior Member

Joined: Thu Jun 13, 2013 7:32 am
Posts: 79
allyn wrote:
Did you start fail2ban? Are you getting any log entries in /var/log/fail2ban? The linode instructions don't mention starting up the service, but it needs doing. There's presumably a right way to start it, but I just rebooted and that knocked down the many hundreds of login attempts per day to almost nothing.


Pretty sure it is running, just restarted it to confirm...

Checked the fail2ban log and see some items like this after restarting the service for each section in my local conf[ (ssh, postfix, dovecot, nginx...):

Code:
iptables -F fail2ban-default
iptables -X fail2ban-default returned 100
2013-08-10 09:48:26,797 fail2ban.jail   : INFO   Jail 'ssh' stopped
2013-08-10 09:48:27,053 fail2ban.actions.action: ERROR  iptables -D INPUT -p tcp -m multiport --dports http,https -j fail2ban


Top
   
 Post subject: Re: Fail2ban issue
PostPosted: Sat Aug 10, 2013 10:21 am 
Offline
Senior Member
User avatar

Joined: Tue Nov 24, 2009 1:59 pm
Posts: 362
Are you, perchance, using the recent 3.9 kernels that Linode offers to you by default and some old-ish distro like Debian 6?

One of my servers went down for a bit because after a reboot it picked up a new kernel, which refused to cooperate with older iptables binaries.

In my case, the rule to "drop all other packets" was accepted, but the two preceding rules to allow specific kinds of data through did not. Might be that your rule to redirect to fail2ban also isn't applied anymore.

_________________
rsk, providing useless advice on the Internet since 2005.


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


Who is online

Users browsing this forum: No registered users and 3 guests


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