LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-15-2006, 10:32 AM   #1
a2vr6
Member
 
Registered: Aug 2006
Posts: 46

Rep: Reputation: 15
hosts.deny not working?


After many years working in a Windows environment I have been moved into a different position at my job working on Unix/Linux systems. We had a c omplaint of hack attempts via ssh to some servers recently. I confirmed the IPS in the log files and compared to what was listed in hosts.deny.

Hosts.deny is setup to deny ssh sessions from all IPs except for a select few. Hosts.allow is empty. Can someone tell me why these rogue IP's are allowed connectivity if they are not on the allow list?? Any help would be much appreciated. Thanks.
 
Old 08-15-2006, 10:50 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,358
Blog Entries: 55

Rep: Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545
I suggest not relying on one line of defense. Since this is really about SSH attempts best read the solutions listed in the Linux Security sticky thread "Failed SSH login attempts" and pick a solution appropriate for your situation.

Here's an excerpt from that may shed a light on what's happening:
Quote:
Originally Posted by ^H^H^H from man 5 hosts_access
. Access will be granted when a (daemon,client) pair matches an
entry in the /etc/hosts.allow file.

. Otherwise, access will be denied when a (daemon,client) pair
matches an entry in the /etc/hosts.deny file.

. Otherwise, access will be granted.
Basically you will want to drop everything from hosts.deny (ALL: ALL) and set up exceptions in hosts.allow.

HTH
 
Old 08-15-2006, 01:43 PM   #3
a2vr6
Member
 
Registered: Aug 2006
Posts: 46

Original Poster
Rep: Reputation: 15
Just wondering how this is different? Will the person trying to ssh into the server get dropped immediately or will they get same message as if it was the other way around?
 
Old 08-15-2006, 02:30 PM   #4
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian
Posts: 2,192

Rep: Reputation: 339Reputation: 339Reputation: 339Reputation: 339
Quote:
Originally Posted by a2vr6
Can someone tell me why these rogue IP's are allowed connectivity if they are not on the allow list??
Is your ssh daemon compiled with tcp_wrappers support?

Look for "libwrap", like this:
Code:
$ whereis sshd
sshd: /usr/sbin/sshd /usr/share/man/man8/sshd.8.gz
$ ldd /usr/sbin/sshd
        linux-gate.so.1 =>  (0xffffe000)
        libwrap.so.0 => /lib/libwrap.so.0 (0xb7f87000)
        libpam.so.0 => /lib/libpam.so.0 (0xb7f7f000)
        libdl.so.2 => /lib/tls/libdl.so.2 (0xb7f7b000)
        libresolv.so.2 => /lib/tls/libresolv.so.2 (0xb7f68000)
        libcrypto.so.0.9.7 => /usr/lib/i686/cmov/libcrypto.so.0.9.7 (0xb7e69000)
        libutil.so.1 => /lib/tls/libutil.so.1 (0xb7e64000)
        libz.so.1 => /usr/lib/libz.so.1 (0xb7e52000)
        libnsl.so.1 => /lib/tls/libnsl.so.1 (0xb7e3c000)
        libcrypt.so.1 => /lib/tls/libcrypt.so.1 (0xb7e0e000)
        libpthread.so.0 => /lib/tls/libpthread.so.0 (0xb7dfc000)
        libc.so.6 => /lib/tls/libc.so.6 (0xb7cc4000)
        /lib/ld-linux.so.2 (0xb7fa0000)
$
You can see the 2nd line of my ldd output lists "libwrap.so.0", so mine is compiled with the required tcp_wrappers support. Most distros are compiled with this support in sshd, but it wouldn't hurt to check - just to make sure. Without such compiled in support, sshd will ignore your hosts.allow or hosts.deny files.
 
Old 08-15-2006, 03:14 PM   #5
a2vr6
Member
 
Registered: Aug 2006
Posts: 46

Original Poster
Rep: Reputation: 15
thanks for the reply. I checked and confirmed it is in fact compiled with the required tcp_wrapper support.
 
Old 08-16-2006, 01:14 PM   #6
a2vr6
Member
 
Registered: Aug 2006
Posts: 46

Original Poster
Rep: Reputation: 15
anyone else have some input?
 
Old 08-16-2006, 01:32 PM   #7
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian
Posts: 2,192

Rep: Reputation: 339Reputation: 339Reputation: 339Reputation: 339
Is there anything in your /var/log/auth.log file that might give you some clue? (file location may be different for your distro) I wouldn't expect much to be there, but check anyway.

Somebody might be able to spot something amiss if you cut/paste the contents of the following files:

/etc/ssh/sshd_config
/etc/hosts.allow
/etc/hosts.deny
 
Old 08-16-2006, 01:48 PM   #8
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389
Hi,

Something else you should check:

Quote:
When you installed TCP wrappers, you should have kept the tcpd.h and libwrap.a files. Usually tcpd.h goes in /usr/local/include and libwrap.a goes in /usr/local/lib. By default, installing TCP wrappers doesn't install these two files, so you may need to grab the TCP wrappers source and recompile it, then install those two files.
This info came from this site (chapter 5.9): ssh faq 5

It's not much, but you never know.
 
Old 08-16-2006, 02:15 PM   #9
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian
Posts: 2,192

Rep: Reputation: 339Reputation: 339Reputation: 339Reputation: 339
Since ldd reports that the OP's sshd is dynamically linked to the libwrap shared library (libwrap.so), he won't need the static version (libwrap.a)
 
Old 08-16-2006, 02:27 PM   #10
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389
Hi,

I see, I thought this had to be done after compiling sshd with wrapper support. Guess you must do it before you start the compile part.

Well, like I stated: It wasn't much and, as turns out it was nothing
 
Old 08-16-2006, 06:42 PM   #11
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally Posted by a2vr6
anyone else have some input?
How about you show us the actual content of /etc/hosts.allow
and /etc/hosts.deny ?

If you're concerned about security you can always anonymise
the IP addresses if they're not in private IP ranges ....


Cheers,
Tink
 
  


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
[SOLVED] question about hosts.allow/hosts.deny Wim Sturkenboom Linux - Security 9 05-30-2006 01:33 AM
/etc/hosts.deny/hosts.allow have no effect on sshd access bganesh Linux - Security 4 05-04-2006 08:06 PM
hosts.allow & hosts.deny question... jonc Linux - Security 9 03-05-2005 09:41 PM
Adding shell commands to hosts.deny and hosts.allow ridertech Linux - Security 3 12-29-2003 03:52 PM
hosts.deny and hosts.allow defaults? gui10 Linux - Security 5 12-20-2001 01:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:30 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration