Operating System - HP-UX
1825576 Members
1953 Online
109682 Solutions
New Discussion

Problem of user restriction with TCP-WRAPPER

 
SOLVED
Go to solution
Lutz_4
Advisor

Problem of user restriction with TCP-WRAPPER


I have correctlly installed tcpwrapper and it works. Now, I want to edit a rule to restirct the telnet access for an unique user from all computers.

For this, I have tiped this line in the /etc/hosts.deny

telnetd : user@ALL

My probleme is that this rule doesn't work. Have you any idee why?
11 REPLIES 11
Keith Bryson
Honored Contributor

Re: Problem of user restriction with TCP-WRAPPER

Hi Lutz

What entry do you have for telnet in the /etc/inetd.conf file?

Keith
Arse-cover at all costs
Keith Bryson
Honored Contributor

Re: Problem of user restriction with TCP-WRAPPER

Hi Lutz

Make sure the telnet line in /etc/inetd.conf resembles the following:

telnet stream tcp nowait root /usr/lbin/tcpd /usr/lbin/telnetd telnetd

and you have restarted inetd using:

inetd -c

Let us know how you get on - Keith
Arse-cover at all costs
Keith Bryson
Honored Contributor

Re: Problem of user restriction with TCP-WRAPPER

Lutz

Having read your post again, I'm not sure that you can use that syntax in the hosts.deny file. According to the tcpd man page, the format should include daemon,client. So you can only restrict/allow the telnetd daemon to IP addresses or domain names.

Keith
Arse-cover at all costs
Lutz_4
Advisor

Re: Problem of user restriction with TCP-WRAPPER

Thank you for your answers.

The syntaxe in the /etc/inetd.conf is good.

Now, I have tried to take the problem by another way :

echo "ALL: ALL" > /etc/hosts.deny
echo "ALL: ALL EXCEPT user@ALL" > /etc/hosts.allow

It doesn't work.
I tried to replace "user@ALL" by an IP addess, and it works.
My problem is the restriction by users and normally it is possible with tcpwrapper (I had a look in my HPUX security training book) !
Keith Bryson
Honored Contributor

Re: Problem of user restriction with TCP-WRAPPER

Hi Lutz

This option can't be available for telnetd - how would Unix know the connecting user before allowing a telnet login prompt? It would obviously know what the user was when they logged in, but the idea of the wrapper is to obviously refuse/allow the telnet session in the first instance. On the other hand, this option IS available for some r services (rsh/remsh etc.). You can deny IPs and domain names, but with telnet, you will need to provide user filtering at the OS level.

Keith
Arse-cover at all costs
Keith Bryson
Honored Contributor

Re: Problem of user restriction with TCP-WRAPPER

OK

Final stab!! If the Unix server has the ability to query the incoming user through their host (be interested to know if it works with telnet), you may need to check a few entries in /etc/tcpd.conf. You may not have this file on the system, if not, copy it from /usr/newconfig/etc/tcpd.conf and set the rfc931_timeout setting to 20 seconds (for example):

# Timeout value for client's user name lookup
##
rfc931_timeout 20

Good luck and let us know how you get on!!

Keith Bryson
Arse-cover at all costs
Lutz_4
Advisor

Re: Problem of user restriction with TCP-WRAPPER

Thank you for this indication but I had already done this modification in the /etc/tcpd.conf
Keith Bryson
Honored Contributor

Re: Problem of user restriction with TCP-WRAPPER

Doh!!

Well, I can only suggest trying this with remsh then (as a test). You will need to modify the login and shell /etc/inetd.conf entries to support the wrapper, then add a rlogind and remshd entry to the /etc/hosts.allow. If it works, you know that the syntax can't be used for telnet.

Hope it helps - Keith
Arse-cover at all costs
Lutz_4
Advisor

Re: Problem of user restriction with TCP-WRAPPER

OK, but if tcpwrapper can't restrict telnet services by users. Have you an idea how can I do to do this ?
TwoProc
Honored Contributor

Re: Problem of user restriction with TCP-WRAPPER

Maybe I'm oversimplifying and missing the boat here - but usually, user level access to telnet and rlogin is limited by user-level accounts and passwords and keys. Machine and domain level security is set at the tcp-wrapper, and ipfilter level. For more restrictions than that ... I'm just at a loss. But, if you can do it, I'm guessing it would have to be at the client machine(s) that the user is coming from. Like maybe implementing a plan for denied access to even run telnet, rlogin, ssh, etc on the client computer.
We are the people our parents warned us about --Jimmy Buffett
Bill Hassell
Honored Contributor
Solution

Re: Problem of user restriction with TCP-WRAPPER

As mentioned, telnet must connect BEFORE asking the user anything. And the program that asks the user name is login, not telnetd. So there is nothing in tcpwrappers that will help. Instead, you add the restriction in /etc/profile (or ..shudder.. /etc/csh.login). /etc/profile must be owned by root and not writable by anyone else. There must be a trap statement pair to keep users from breaking out of the /etc/profile script:

...
trap "" 1 2 3
...rest of profile...
trap 1 2 3

This tells the login shell to do nothing if the user tries to escape using CTRL-C, etc. Standard HP profile has this (see /usr/newconfig/etc/profile). In /etc/profile, near the top, create the disallowed user code. In it's simplest format:

BADUSER=billh
[ $(id -un) = $BADUSER ] && exit

Now, you may have a list of bad users in a file so the code becomes:

BADUSERFILE=/etc/baduser
if [ -r $BADUSERFILE ]
then
cat $BADUSERFILE | while read BADUSER
do
[ $(id -un) = $BADUSER ] && exit
done
fi

And you might want to log these attempts in case there is a security problem:

BADUSERFILE=/etc/baduser
if [ -r $BADUSERFILE ]
then
cat $BADUSERFILE | while read BADUSER
do
if [ $(id -un) = $BADUSER ]
then
REMOTE=$(who -muR | awk '{print $NF}')
logger -t /etc/profile -p daemon:warn "User $BADUSER tried to login from $REMOTE"
fi
done
fi


Bill Hassell, sysadmin