LinuxQuestions.org
Visit the LQ Articles and Editorials section
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-04-2004, 10:58 PM   #1
archdev
Member
 
Registered: May 2004
Location: chicago and cincinnati
Distribution: fedora
Posts: 134

Rep: Reputation: 15
numerous ssh attempts


Have any of your guys noticed a lot of brute force attempts on your sshd?

I get about 10 hits a day or so trying our users 'test,' 'guest,' 'user,' and 'root.' None of these can get access to my box via ssh, so I don't care so much, but with only these usernames always tried and the time between attempts a second or two between tries makes me think script kiddies or like someone's box was compromised.

I have reported some of it to the orginating domain, but when I get like 3 or different IP's in a day, I just get lazy.

Anyway, second question: can you fake the IP that these attemps would come from, so that in your /var/log/secure file, the IP's of the originating computer are in fact wrong?
 
Old 08-04-2004, 11:09 PM   #2
ppuru
Senior Member
 
Registered: Mar 2003
Location: Beautiful BC
Distribution: RedHat & clones, Slackware, SuSE, OpenBSD
Posts: 1,791

Rep: Reputation: 46
Yes, my sshd has logged several tries as guest and test. I already have the AllowUser keyword that restricts access. So I believe sshd won't buclke in.
 
Old 08-04-2004, 11:27 PM   #3
Capt_Caveman
Senior Member
 
Registered: Mar 2003
Distribution: Fedora
Posts: 3,658

Rep: Reputation: 57
This seems to be getting fairly widespread. See the bottom of:

http://isc.sans.org/diary.php?date=2004-08-04

Might even want to submit a copy of your logs to SANS.

Last edited by Capt_Caveman; 08-09-2004 at 11:50 AM.
 
Old 08-05-2004, 02:58 AM   #4
dominant
Member
 
Registered: Jan 2004
Posts: 409

Rep: Reputation: 30
Why don't you use tcp wrappers to restrict these login attempts?
 
Old 08-05-2004, 06:52 AM   #5
archdev
Member
 
Registered: May 2004
Location: chicago and cincinnati
Distribution: fedora
Posts: 134

Original Poster
Rep: Reputation: 15
tcp wrappers? (sorry I am still new to all of this)
 
Old 08-05-2004, 07:16 AM   #6
ppuru
Senior Member
 
Registered: Mar 2003
Location: Beautiful BC
Distribution: RedHat & clones, Slackware, SuSE, OpenBSD
Posts: 1,791

Rep: Reputation: 46
if you know the IPs / subnets you expect ssh connections from, you can add these to your /etc/hosts.allow. Any IPs/subnets not listed in hosts.allow will not be allowed to connect to your box.

you can

#man hosts.allow

for more information.
 
Old 08-05-2004, 07:30 AM   #7
dominant
Member
 
Registered: Jan 2004
Posts: 409

Rep: Reputation: 30
But the problem is if tcp wrappers could be violated.
 
Old 08-05-2004, 08:44 AM   #8
stickman
Senior Member
 
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552

Rep: Reputation: 53
Filter ssh access from known clients with iptables.
 
Old 08-09-2004, 02:32 AM   #9
Jedyte
LQ Newbie
 
Registered: Aug 2004
Posts: 10

Rep: Reputation: 0
Yes, I get a lot of these too! Is there a way to automatically blacklist when someone tries these? No-one should ever login with 'test','guest' or 'admin' so I can safely assume they're malicious.
 
Old 08-10-2004, 02:02 AM   #10
barisdemiray
Member
 
Registered: Sep 2003
Location: Ankara/Turkey
Distribution: Slackware
Posts: 155

Rep: Reputation: 30
Quote:
Originally posted by Jedyte
Yes, I get a lot of these too! Is there a way to automatically blacklist when someone tries these? No-one should ever login with 'test','guest' or 'admin' so I can safely assume they're malicious.
You can parse and add the IP's into a list but there are so many people connectiong internet thorugh dial-up and taking dynamic IP. So when you blacklist an IP, it can be given to another user and lamer one can get a fresh-and-clean IP that isn't in your blacklist. But i think you can decide up to ssh attempt frequency; i mean if you're getting attempts from an IP for a long time then it can be a static lamer :-)
 
Old 08-10-2004, 08:11 AM   #11
Bebo
Member
 
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Rep: Reputation: 30
First your second question, archdev; yes, it is possible to spoof the IP address, so that you don't see the proper one in the log. However, the attack would be blind since the responses from your sshd will go to the "apparent" IP address, i.e. the logged IP. To carry through such as attack requires more knowledge than I believe the average script-kiddie possesses.

As barisdemiray said, it is perhaps not very useful to block specific IPs, but if you often see the same IP then it might be worth it. However, it is better to set up a whitelist and deny access from IP's and users not in that list. You have a number of places where you can put these whitelists.

1) In the sshd config file (/etc/ssh/sshd_config) you can use the AllowUsers entry to whitelist users. Other entries of interest in this file are PermitRootLogin, LoginGraceTime, MaxStartups, and maybe some others. See the manpage of sshd_config for more info.

2) Use tcpwrappers as mentioned above. Whitelist allowed IP's in /etc/hosts.allow using the syntax sshd:allowed.ip.here - one for each line. Groups of IPs can be allowed with the notation sshd:192.168.52. which would allow IPs in the range 192.168.52.0-255. The file should end with a line like all:all:deny . Your /etc/hosts.deny should contain the rule all:all .

3) Setup iptables to allow connection requests from certain IPs and block the rest. If you know there will be few connection requests and not very often, you can limit the number of connection requests to one per minute or whatever; that would slow brute-forcing.

4) Change the sshd port from 22 to something else, like 50897. This is security by obscurity and is certainly not good enough on it's own, but might confuse an attacker.

Oh yes, and look up the Protocol entry in /etc/ssh/sshd_config. Make sure it says Protocol 2 and not Protocol 2,1.

Have fun!
 
Old 08-10-2004, 08:24 AM   #12
Jedyte
LQ Newbie
 
Registered: Aug 2004
Posts: 10

Rep: Reputation: 0
Thanks for the information, Bebo!

Quote:
Originally posted by Bebo Oh yes, and look up the Protocol entry in /etc/ssh/sshd_config. Make sure it says Protocol 2 and not Protocol 2,1.
Why is that? Could you explain the advantage?
 
Old 08-10-2004, 08:49 AM   #13
archdev
Member
 
Registered: May 2004
Location: chicago and cincinnati
Distribution: fedora
Posts: 134

Original Poster
Rep: Reputation: 15
Yea I have

Code:
#Protocol 2,1
By default is it set to 2,1... and yes, what is the difference between protocol 1 vs 2.
 
Old 08-10-2004, 09:09 AM   #14
Bebo
Member
 
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Rep: Reputation: 30
The Protocol 2,1 in the sshd_config means that the server should use version 1 as a fallback if protocol 2 fails. I don't know if it's an issue any more, but protocol version 1 has been flawed in the past. Version 2 is newer and said to be more secure, so I think that a fallback to something less secure should be avoided. Version 1 is almost obsolete since it's only used by very old ssh versions, and I would not trust anyone who still uses it. Correct me if I'm wrong please

<EDIT>
I've forgotten where I read that one should skip Protocol 1, so I'm doing some searches. I just found the following here:
Quote:
Use only ssh protocol 2; version 1.33 and 1.5 of ssh protocol is not completely cryptographically safe (according to Nessus probe)
...
OK, see here and here.
</EDIT>

Last edited by Bebo; 08-10-2004 at 09:30 AM.
 
Old 08-10-2004, 04:14 PM   #15
Anon123
LQ Newbie
 
Registered: Jun 2004
Posts: 6

Rep: Reputation: 0
Install BFD. It will ban the IPs that constantly attempt to login and fail.

http://www.rfxnetworks.com/bfd.php
 
  


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
SSH login attempts Capt_Caveman Linux - Security 225 11-07-2009 09:55 AM
SSH Alert when root attempts to log gamehack Linux - Software 3 06-03-2009 06:44 AM
SSH tricks -- any way to block failed attempts by IP address tensigh Linux - Security 10 06-06-2008 03:46 PM
Failed SSH login attempts Capt_Caveman Linux - Security 38 01-03-2006 03:22 PM
ssh login attempts from localhost?! sovietpower Linux - Security 2 05-29-2005 01:19 AM


All times are GMT -5. The time now is 09:22 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration