LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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-02-2007, 06:32 PM   #1
badfrog
LQ Newbie
 
Registered: Jul 2007
Location: Louisville, KY
Distribution: Slackware, Debian and LFS (soon!)
Posts: 14

Rep: Reputation: 0
Couple ssh questions


Hey guys, just recently started experimenting with ssh on my personal desktop, read the excellent sticky thread here, and based on that advice, I've locked down sshd_config to deny access to a bunch of accounts that I see as attack vectors (apache, root, users not in the users group, etc). Very helpful stuff!

I've got a couple questions though...
1) Where are the ssh connection logs, the ones that include user/password combinations kept? I've poked around in /var/logs and looked at the tails of secure and syslog and grepped for ssh, but don't see anything there, and there are no other files that look really promising.

2) syslog contains lots of messages like "error: Could not get shadow information for NOUSER." Google got me some results that indicate these are failed logins due to an invalid user. Where could I go to find out more information about these, like a source IP or domain?

This is Slack 12 if it makes any difference.

Thanks!
 
Old 08-02-2007, 07:33 PM   #2
binary_pearl
Member
 
Registered: Jul 2007
Location: Chicago Illinois
Distribution: SLES 10 SP2/SP3, SLES 11 SP1, OpenSUSE, Sabayon, Gentoo, Fedora 14, RHEL 3/4/5/6
Posts: 98
Blog Entries: 3

Rep: Reputation: 23
The file /var/log/messages should give you information about people trying to connect to your server. If your computer is publicly available (no firewall blocking port 22), you will most likely see lot's of failed brute force attempts to get in.

Quote:
"error: Could not get shadow information for NOUSER."
I believe this message could from an attempted ssh brute force attempt.
You have a couple of options in order to prevent these attacks. You could run ssh on a different port besides 22, but if you have other people besides yourself logging in, that might be kind of a hassle.

iptables could be used to limit the amount of connections per a given amount of time. So let's say you could limit 10 maximum connections per minute.

My favorite was to write a script that drops the packets of an offending ip address after 10 failed attempts. I believe some of the attacks come from either spoofed ip's or they are coming from under a larger network. I tried tracing the ip of one attack and I ended up at the website of a Chinese ISP. So you can block the ip's, but it may not truly stop the attacker. But it will stop the current attack. If you are interested in the script, let me know and I'll post it.

Another thing that you may want to consider if you haven't done so already is to prevent root login through ssh. You would then need to have a user account on the system before you can log in as root. You can make this change in the (I belive) sshd.conf file.

--Shaun
 
Old 08-02-2007, 08:00 PM   #3
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
http://www.aczoom.com/cms/blockhosts/download

This script does a nice job of monitoring and blocking SSH attacks.
 
Old 08-03-2007, 08:37 AM   #4
badfrog
LQ Newbie
 
Registered: Jul 2007
Location: Louisville, KY
Distribution: Slackware, Debian and LFS (soon!)
Posts: 14

Original Poster
Rep: Reputation: 0
I had thought about moving the service off the default port, and I may wind up doing that. This box is firewalled and natted at the router with just the ssh port forwarded (currently), and I'm likely the only one who will use it from outside the LAN, so changing the external port might be the best idea.

Quote:
Originally Posted by binary_pearl
Another thing that you may want to consider if you haven't done so already is to prevent root login through ssh.
That was the first thing I did. Thanks.
 
Old 08-03-2007, 08:59 AM   #5
bakfupai
Member
 
Registered: Apr 2006
Location: Sweden
Distribution: CentOS, RHEL, SourceMage, OpenBSD
Posts: 40

Rep: Reputation: 15
The log might be called auth.log. Otherwise you should be able to locate it by running:
grep sshd /var/log/*
or:
find /var/log -exec grep -H 'sshd' '{}' \;
(if it's located in a sub-directory)

Anyway, I usually protect myself against the "random" ssh attacks by setting up key-based login and turning off password authentication. Then the attacker won't even get a login prompt and it's pretty convenient if you're the only one accessing the computer
 
Old 08-03-2007, 09:06 AM   #6
Lothar Schwab
LQ Newbie
 
Registered: Aug 2007
Location: Minnesota, USA
Distribution: Lubuntu
Posts: 19

Rep: Reputation: 2
Quote:
Originally Posted by badfrog
I had thought about moving the service off the default port, and I may wind up doing that.
I did exactly that and since then I recorded only
one attempt of an outside computer to connect to this
port. I am pretty sure that this was simply a port
scan.

Doing this port change is only security by obscurity.
It is a good idea to do so. But it is a bad idea to
rely on it and to think that no other security
measures need to be taken (I am not implying that
you think that - this is only a general statement).
 
Old 08-03-2007, 02:41 PM   #7
badfrog
LQ Newbie
 
Registered: Jul 2007
Location: Louisville, KY
Distribution: Slackware, Debian and LFS (soon!)
Posts: 14

Original Poster
Rep: Reputation: 0
I found them, they are in /var/log/messages. Got several hundred a few seconds apart from somewhere in China trying usernames in alphabetical order.

Bah. I tried moving the service to port 44 (which was easy to remember, and also seemed to be not reserved by any other well-known services), but my stupid Linksys router refuses to forward that port for some reason. Buggy piece of crap.

I'm not crazy about a key-based login in this instance because I'm a contractor who changes jobs a lot, sometimes without much notice, and I'm paranoid about leaving a key behind somewhere. I know, I can revoke them, but still.
 
Old 08-03-2007, 03:42 PM   #8
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Quote:
Originally Posted by badfrog
I'm not crazy about a key-based login in this instance because I'm a contractor who changes jobs a lot, sometimes without much notice, and I'm paranoid about leaving a key behind somewhere.
To mitigate that risk you could:
  • Protect your key with a passphrase.
  • Generate a new keypair each time you change jobs (it's not that time intensive). Remember to delete the old public key from ~/.ssh/authorized_keys.

Carry the new private key on a usb pen drive to your new job...
 
  


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
A couple questions.. Saurian Linux - Newbie 6 08-27-2006 08:43 PM
Couple of questions please tommytomato Linux - Newbie 7 06-07-2004 09:31 PM
a couple questions maybbach Linux - Newbie 7 04-14-2004 11:30 PM
Couple of questions... p3ngu!n Linux - Newbie 2 11-11-2003 05:41 AM
A couple of questions LarcTongi Linux - General 1 03-14-2001 12:48 PM

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

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