LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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-07-2006, 06:43 AM   #1
blackcat_73
LQ Newbie
 
Registered: Oct 2006
Posts: 13

Rep: Reputation: 0
TCPwrappers and user access


Hi, I have the following configuration on my hosts.deny and hosts.allow:

/etc/hosts.deny
ALL : ALL

/etc/hosts.allow
ALL : 127.0.0.1

What I want is to allow a specific user to connect to ssh server from anywhere, something like:

sshd: <usrname>@ALL

but this isn't working, can someone tell me how to do this?

Thanks,
Bruno
 
Old 11-07-2006, 07:32 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
tcpwrappers can not know what a user name is, that's something handled by the daemon it is wrapping, and at TCP level there is no such concept as a user name. tcpwrappers does support RFC931 http://www.faqs.org/rfcs/rfc931.html but that itself relies on finger services on the client side to tell tcpwrappers outside of the appliction who the user is. it's really no use unless you control both the client and the server.

Last edited by acid_kewpie; 11-07-2006 at 07:34 AM.
 
Old 11-07-2006, 07:38 AM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
/etc/hosts.allow
ALL : 127.0.0.1

You'll have to add a line with the first argument set to the argv[0] of the binary ("sshd" in this case) and allow the subnets the user is allowed from. With "/24" subnet type notation just chop of the last octet. Example with subnet "11.22.33.44":
sshd: 127.0.0.1, 11.22.33.,
This will allow anyone with access through ssh to connect. "man 5 hosts_access" for more info.
Also make sure your firewall policy reflects this policy.

Now set in sshd_config the AllowUsers directive to "user@host" and make sure you include all the users that are allowed in. (You can also use the PAM listfile module instead, but that only works with usernames, no hosts, unless you also set access.conf.) If you want to further restrict subnets this user is allowed in from you can add "from="127.0.0.1,11.22.33.44"" to the users ~/.ssh/authorized_keys key entry, unless the user needs to change (add authed keys to) the file.
 
Old 11-07-2006, 08:12 AM   #4
blackcat_73
LQ Newbie
 
Registered: Oct 2006
Posts: 13

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by unSpawn
/etc/hosts.allow
ALL : 127.0.0.1

You'll have to add a line with the first argument set to the argv[0] of the binary ("sshd" in this case) and allow the subnets the user is allowed from. With "/24" subnet type notation just chop of the last octet. Example with subnet "11.22.33.44":
sshd: 127.0.0.1, 11.22.33.,
This will allow anyone with access through ssh to connect. "man 5 hosts_access" for more info.
Also make sure your firewall policy reflects this policy.
But I want to access from several different places, not only a subnet, and my firewall policy is according.
Can I take this approach:

sshd : ALL

and allow only my username using sshd_config?
Also, can I change ALL : 127.0.0.1 to ALL : LOCALHOST? Is it the same?

Thanks for all.

Last edited by blackcat_73; 11-07-2006 at 08:15 AM.
 
Old 11-07-2006, 08:16 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
absolutely, yes. it's not until you get to ssh itself that the idea of a username comes into existance, but once it has you can certainly leverage a combination of tcpwrappers and sshd_config to control things quite tightly.
 
  


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
Dovecot and tcpwrappers in FC3? jonsson Fedora 1 08-09-2010 03:53 AM
tcpwrappers & xinted? hank43 Linux - Security 3 10-30-2006 05:10 AM
portsentry separate logs and TCPwrappers gabsik Linux - Security 5 04-05-2006 08:08 AM
I lose ftp access when I disable shell access for user captainObvious Linux - General 3 11-13-2004 05:49 PM
Do I need an firewall if I set my tcpwrappers like this? rbrasil Linux - Security 7 12-18-2003 10:19 AM

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

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