LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 10-04-2005, 11:26 PM   #1
mattp
Member
 
Registered: Mar 2004
Location: Chicago, USA
Distribution: Slackware 10.2
Posts: 368

Rep: Reputation: 30
Alert when root pw is being guessed at


I have my server open to SSH connections. I need a script that will email me if the root password was incorrectly entered 5 times. Anyone have any ideas?
 
Old 10-04-2005, 11:46 PM   #2
freakyg
Member
 
Registered: Apr 2005
Distribution: LFS 5.0 and 6.1
Posts: 705

Rep: Reputation: 30
part of setting up tcp wrappers is to dis-allow root access via ssh...........just make sure that your root password cannot be guessed or brute forced.......( it would take JTR 500+ years to guess my root pass........LOL)

script kiddie crackers can use proxies and spoof UDP packets to hide their IP .......so having an alert setup would do no good anyways........
 
Old 10-04-2005, 11:49 PM   #3
mattp
Member
 
Registered: Mar 2004
Location: Chicago, USA
Distribution: Slackware 10.2
Posts: 368

Original Poster
Rep: Reputation: 30
I'm not concerned who is guessing at it, just that it is trying to be guessed. Maybe SSH could be locked out after the 5th try at root pw. I want to access root from SSH because I want to do admin things on the server from abroad.
 
Old 10-05-2005, 12:39 AM   #4
gbonvehi
Senior Member
 
Registered: Jun 2004
Location: Argentina (SR, LP)
Distribution: Slackware
Posts: 3,145

Rep: Reputation: 53
Then disallow login as root. And configure the su command to be used only from another account you create yourself just to login and su to root from there.
Allowing directly root login as bad, because the crackers already know the username. The way I'm suggesting you, they will have to know the username you are allowing to su, so they may enter in another account, but they won't still be able to su from there.

Last edited by gbonvehi; 10-05-2005 at 12:42 AM.
 
Old 10-05-2005, 12:43 AM   #5
mattp
Member
 
Registered: Mar 2004
Location: Chicago, USA
Distribution: Slackware 10.2
Posts: 368

Original Poster
Rep: Reputation: 30
Ah, good point. Thanks!
 
Old 10-05-2005, 12:54 AM   #6
gbonvehi
Senior Member
 
Registered: Jun 2004
Location: Argentina (SR, LP)
Distribution: Slackware
Posts: 3,145

Rep: Reputation: 53
You're welcome

Forgot to say that you also should change your SSH port to something else, that will prevent 99% of the attacks, since they're most directed to port 22.

There are also some utilities that will block IPs if they fail to login on SSH on X tries, like: http://www.csc.liv.ac.uk/~greg/sshdfilter/
 
Old 10-05-2005, 01:24 AM   #7
Yalla-One
Member
 
Registered: Oct 2004
Location: Norway
Distribution: Slackware, CentOS
Posts: 641

Rep: Reputation: 36
Just to follow-up on various very good suggestions, the best of them being definitely to disallow root login, I have included below what I've done to secure sshd:

1. On my gateway running NAT I have mapped a non-standard port to be forwarded to my server's ssh port, so that the normal script-kiddies don't get a hit on port 22 off the bat

2. On my server (running ssh) I have included the following statement in iptables to limit ssh to allow only one new ssh connection each 30 seconds :

Code:
iptables -A INPUT -p tcp -m state --state NEW --dport 22 -m recent --update --seconds 25 -j DROP
iptables -A INPUT -p tcp -m state --state NEW --dport 22 -m recent --set -j ACCEPT
3. In /etc/ssh/sshd_config I have made a number of changes

Protocol 2 # Changed from Protocol 2,1 - allow only ssh v2 - more secure
PermitRootLogin No #NEVER EVER login as root - as addressed by previous thread writers
MaxAuthTries 2 #Changed from default 5
AllowUsers nnnn # Only one username which is un-guessable (and has STRONG password)
IgnoreRHosts Yes
PermitEmptyPasswords No

4. Check your /var/log/messages frequently

and if you're very security conscious:

5. Install a port-blocker that reads your logs and automagically reprograms iptables to lock-out the offending addresses if someone try to break in.
See http://daemonshield.sourceforge.net/ or http://www.simonzone.com/software/guarddog/ for examples, though there are many more programs available too.

-Y1
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SSH Alert when root attempts to log gamehack Linux - Software 3 06-03-2009 06:44 AM
Hi. I'm new! (wow... who would have guessed) everbloom LinuxQuestions.org Member Intro 1 03-24-2004 03:43 PM
You guessed it ALSA Problems :D (I have searched) GT_Onizuka Slackware 17 12-06-2003 05:12 PM
sound on rh8 (you've guessed it ac'97!) Ian_Hawdon Red Hat 4 09-06-2003 09:24 AM
ALERT!!! ALERT!!! I messed up the UNIX!!! Firew Linux - Software 1 11-05-2001 11:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 06:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration