LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 08-13-2004, 09:32 AM   #1
mazzo
Member
 
Registered: Jun 2003
Location: Thames Valley, UK
Distribution: RedHat from 4 -9, Fedora, Ubuntu, Centos 3 - 7, Puppy Linux, and lots of raspberry pi
Posts: 142

Rep: Reputation: 15
ssh auto shutdown


Hi

With the increase in ssh scans and attempted break-ins (using test, guest, admin etc usernames), is there a way to get ssh to close down if there are a number of unsuccessful attempts at logging in?

I intend to make ssh available for only a couple of users - and I think I know how to sort that out (sshd_config).

I want it so that if someone did manage to guess a valid username, then sshd would shutdown after a predefined number of failed attempts (ie the password is wrong).

If this was covered elsewhere, I couldn't find it.

Thanks
 
Old 08-13-2004, 11:06 AM   #2
TBC Cosmo
Member
 
Registered: Feb 2004
Location: NY
Distribution: Fedora 10, CentOS 5.4, Debian 5 Sparc64
Posts: 356

Rep: Reputation: 43
Re: ssh auto shutdown

Quote:
Originally posted by mazzo
Hi

With the increase in ssh scans and attempted break-ins (using test, guest, admin etc usernames), is there a way to get ssh to close down if there are a number of unsuccessful attempts at logging in?

I intend to make ssh available for only a couple of users - and I think I know how to sort that out (sshd_config).

I want it so that if someone did manage to guess a valid username, then sshd would shutdown after a predefined number of failed attempts (ie the password is wrong).

If this was covered elsewhere, I couldn't find it.

Thanks
1. Its doubtful that someone will hang around long enough to actually guess an account. These scans test for dumb accounts and dump a rootkit or something. They check for these stupid accounts and if not found, move on. They have better success rates doing that.

2. With a good password, It could take a very long time to brute force an account even on a known login name. Meanwhile, the logs are filling up with failed attempts, and PAM can disable the account if certain # failed tries.

3. Use ssh PK auth with ssh-agent and/or PuTTY agent and config sshd to allow only key auth. That way, if by some miracle, a password is guessed, the connection fails since there is no corresponding key at the other end.

4. Config tcp_wrappers to allow only those users if they have static IP, or by range of their IPs if dynamic. Deny all else. That way you at least eliminate china, russia, canada, texas etc.

There's more, but I think these are good without going to extremes.
 
Old 08-13-2004, 11:51 AM   #3
mazzo
Member
 
Registered: Jun 2003
Location: Thames Valley, UK
Distribution: RedHat from 4 -9, Fedora, Ubuntu, Centos 3 - 7, Puppy Linux, and lots of raspberry pi
Posts: 142

Original Poster
Rep: Reputation: 15
Thanks - that's good advice.

I have bolted ssh down to only 2 users - so am limiting the availability of legal logins.

Very interested in your PAM comment. I would be keen to know how I implement the x failed attempts, then shutdown.

Conversely, if it does get shut down, is there a way to re-start it at a certain period after shutdown. Is this a cron task?

Thanks
 
Old 08-13-2004, 01:07 PM   #4
TBC Cosmo
Member
 
Registered: Feb 2004
Location: NY
Distribution: Fedora 10, CentOS 5.4, Debian 5 Sparc64
Posts: 356

Rep: Reputation: 43
I would'nt go to the trouble of killing the ssh server, just lock the user's account.

Code:
auth        required      /lib/security/pam_env.so
auth        required      /lib/security/pam_tally.so onerr=fail no_magic_root
auth        sufficient    /lib/security/pam_unix.so likeauth nullok
auth        required      /lib/security/pam_deny.so

account     required      /lib/security/pam_unix.so
account     required      /lib/security/pam_tally.so deny=3 no_magic_root reset
password    required      /lib/security/pam_cracklib.so retry=3 minlen=8 dcredit
=-1 ocredit=-1 ucredit=-1 lcredit=-1
password    sufficient    /lib/security/pam_unix.so nullok use_authtok md5 shado
w remember=15
password    required      /lib/security/pam_deny.so

session     required      /lib/security/pam_limits.so
session     required      /lib/security/pam_unix.so
This causes pam to lock the user's account after 3 failed attempts. To find failed logins using the pam_tally module, type pam_tally, and to reset, do pam_tally --user user --reset
 
Old 08-13-2004, 05:55 PM   #5
mazzo
Member
 
Registered: Jun 2003
Location: Thames Valley, UK
Distribution: RedHat from 4 -9, Fedora, Ubuntu, Centos 3 - 7, Puppy Linux, and lots of raspberry pi
Posts: 142

Original Poster
Rep: Reputation: 15
Thanks - I will give it a go!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
network connection auto shutdown :( doughammond Linux - Networking 4 10-15-2003 01:59 PM
Auto Shutdown k_ranju Linux - General 3 07-20-2003 04:43 AM
how to auto powerdown at shutdown (slackware9.0) fysx Linux - Hardware 1 05-09-2003 03:19 PM
how to auto powerdown at shutdown fysx Linux - Software 1 05-09-2003 03:09 PM
Auto Shutdown at time Crazy Banana Linux - General 3 11-26-2002 07:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 03:43 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