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 11-30-2010, 01:55 PM   #1
rileymartin
LQ Newbie
 
Registered: Oct 2009
Posts: 17

Rep: Reputation: 0
Monitoring ssh - How to get IP from failed logins


Hi,

How do I monitor who is ssh'ing into a box (SLES) as well as failed attempts? How can I log their IP addresses, even if they're not in DNS? In /var/log/messages I see their hostname but no IP address.

Thanks,

Riley
 
Old 11-30-2010, 02:06 PM   #2
sys64738
Member
 
Registered: May 2008
Location: NRW/Germany
Posts: 105

Rep: Reputation: 30
Hi,
I have no SLES available right now but AFAIK you find that information in "/var/log/auth.log".

Last edited by sys64738; 11-30-2010 at 02:08 PM.
 
Old 11-30-2010, 02:09 PM   #3
rileymartin
LQ Newbie
 
Registered: Oct 2009
Posts: 17

Original Poster
Rep: Reputation: 0
Thanks for the reply but I looked and there is no /var/log/auth
 
Old 11-30-2010, 02:28 PM   #4
rileymartin
LQ Newbie
 
Registered: Oct 2009
Posts: 17

Original Poster
Rep: Reputation: 0
I wasn't sure if that was logged anywhere. I did try the following:

watch 'netstat -anp | grep :22' >> iplog.txt

But that doesn't actually append to the file, it just overwrites. I was hoping to 'catch' the IP as it connected on port 22.
 
Old 11-30-2010, 03:17 PM   #5
sys64738
Member
 
Registered: May 2008
Location: NRW/Germany
Posts: 105

Rep: Reputation: 30
Quote:
Originally Posted by rileymartin View Post
Thanks for the reply but I looked and there is no /var/log/auth
Just to be sure. There is no "/var/log/auth.log"? I have made a typo in my post but I corrected it.
 
Old 11-30-2010, 03:27 PM   #6
rileymartin
LQ Newbie
 
Registered: Oct 2009
Posts: 17

Original Poster
Rep: Reputation: 0
I checked and there is no auth.log file.
 
Old 11-30-2010, 03:30 PM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599
OpenSUSE uses PAM so IIRC that should be /var/log/secure or whatever syslog sends PAM messages (authpriv facility) to: see /etc/.*syslog.*.conf. Wrt logging failed logins I suggest overcoming the idea there's a need to reinvent the wheel and use fail2ban. See http://www.linuxquestions.org/questi...tempts-340366/ for more.
 
Old 11-30-2010, 03:44 PM   #8
sys64738
Member
 
Registered: May 2008
Location: NRW/Germany
Posts: 105

Rep: Reputation: 30
Hmm
There should be a logfile "/var/log/secure".
If not look in "/etc/syslog.conf" there is a line starting with "auth.*" the name of the file carrying that log follows.
 
Old 12-01-2010, 08:46 AM   #9
rileymartin
LQ Newbie
 
Registered: Oct 2009
Posts: 17

Original Poster
Rep: Reputation: 0
I don't see the /var/log/secure file either.

There also isn't any /etc/syslog.conf.

There is a /etc/sysctl.conf however.

cat sysctl.conf
# Disable response to broadcasts.
# You don't want yourself becoming a Smurf amplifier.
net.ipv4.icmp_echo_ignore_broadcasts = 1
# enable route verification on all interfaces
net.ipv4.conf.all.rp_filter = 1
# enable ipV6 forwarding
#net.ipv6.conf.all.forwarding = 1
# everything after this comment added by jm 12-15-2009
# increase TCP max buffer size setable using netsockopt()
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
# increase Linux autotuning TCP buffer limits
# min, default, and max number of bytes to use
# set max to at least 4MB, or higher if you use very high BDP paths
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
# don't cache sshthresh from previous connection
net.ipv4.tcp_no_metrics_save = 1
net.ipv4.tcp_moderate_rcvbuf = 1
# recommended to increase this for 1000 BT or higher
net.core.netdev_max_backlog = 2500
 
Old 12-01-2010, 10:18 AM   #10
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599
Quote:
Originally Posted by rileymartin View Post
There also isn't any /etc/syslog.conf.
You should get to know your system. AFAIK SLES10 seems to use syslog-ng so that'll be /etc/syslog-ng.conf or /etc/syslog-ng/syslog-ng.conf.
 
Old 12-02-2010, 02:05 PM   #11
rileymartin
LQ Newbie
 
Registered: Oct 2009
Posts: 17

Original Poster
Rep: Reputation: 0
I was able find what needed to be updated.

In the /etc/ssh/sshd_config file change the setting

UseDNS yes

to

UseDNS no

The failed ssh logins will then show up in /var/log/messages with the IP Addresses instead of the DNS/host names.
 
Old 12-03-2010, 07:38 AM   #12
unixfool
Member
 
Registered: May 2005
Location: Northern VA
Distribution: Slackware, Ubuntu, FreeBSD, OpenBSD, OS X
Posts: 782
Blog Entries: 8

Rep: Reputation: 158Reputation: 158
Congrats!

Now, can you mark this thread as 'solved'?
 
Old 12-03-2010, 08:28 AM   #13
Dani1973
Member
 
Registered: Dec 2010
Distribution: Debian testing
Posts: 148

Rep: Reputation: 16
Just curious, isn't this a waste of time?

My boxes get thousands of failed SSH logins each day.
All you get is a long list of proxies from some weird countries
 
Old 12-03-2010, 08:39 AM   #14
unixfool
Member
 
Registered: May 2005
Location: Northern VA
Distribution: Slackware, Ubuntu, FreeBSD, OpenBSD, OS X
Posts: 782
Blog Entries: 8

Rep: Reputation: 158Reputation: 158
It pays to at least look at who knocked on the door.

It tends to be more difficult doing this after you've been compromised.

Tools such as logwatch help, though.
 
  


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
RH 4 logging of accounts locked after failed logins jkilpat Linux - Security 3 09-04-2009 05:06 PM
Configure Failed logins to lock accounts after 5 failed attempts mccartjd Linux - Newbie 5 05-05-2008 08:02 AM
SSH Failed Password Monitoring KPOM Linux - Security 1 10-09-2004 11:25 PM
X11 display failed logins rangerx Linux - Security 0 09-19-2002 10:39 AM

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

All times are GMT -5. The time now is 05:10 PM.

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