Operating System - HP-UX
1748002 Members
4679 Online
108757 Solutions
New Discussion юеВ

Restict number of telnet sessions

 
KapilRaj
Honored Contributor

Restict number of telnet sessions

Can I do this ?.

My telnetd service should refuce conenctions after it has reached a number (say 100)

Regds,

Kaps
Nothing is impossible
8 REPLIES 8
Mark Grant
Honored Contributor

Re: Restict number of telnet sessions

You could try and install xinetd instead of inetd but this will probably cause you a few issues.

Otherwise, you could script it in /etc/profile. Something like

[ `ps -ef | grep -v grep | grep telnetd | wc -l` -gt 100 ] && exit
Never preceed any demonstration with anything more predictive than "watch this"
Radhakrishnan Venkatara
Trusted Contributor

Re: Restict number of telnet sessions

kaps,

you can do that.Once i faced the problem after 70 users i am not able to getting telnet connection.So I had to increase the some kernel parameters such as NPTY NSTRPTY and created the device files.I dunno whether the vice-versa will work.
I never tried that.

Regds

Radhakrishnan
Negative thinking is a highest form of Intelligence
Mark Grant
Honored Contributor

Re: Restict number of telnet sessions

trouble with that one Radhakrishnan is that it would not just restrict telnet. You wouldn't be able to do all sorts of other networking type connections or even have many users with several xterms open.
Never preceed any demonstration with anything more predictive than "watch this"
KapilRaj
Honored Contributor

Re: Restict number of telnet sessions

This is not really what i want. I want telnetd to reject anything after the 100th telnet connection onto it.

Regds,

Kaps
Nothing is impossible
Mark Grant
Honored Contributor

Re: Restict number of telnet sessions

I think xinetd is your only option here then. xinetd is a replacement for inetd but it does allow you to specifiy the number of instances of a service.

They don't have it at the porting center but it does compile on hpux.
Never preceed any demonstration with anything more predictive than "watch this"
T G Manikandan
Honored Contributor

Re: Restict number of telnet sessions

The thing would be to restrict the number with the kernel parameter nstrtel.

If this is set to 100 and there are 100 telnet connections open,then it would reject new connections.

Tim Sanko
Trusted Contributor

Re: Restict number of telnet sessions

All Hail the pharaoh!! he has it right.
Bill Hassell
Honored Contributor

Re: Restict number of telnet sessions

Depending on how the users make their connection (Xwindows makes it complicated) and the version of HP-UX you are using, just set the 3 kernel parameters: npty, nstrtel and nstrpty all equal to 100. As mentioned, this can affect other services, so you may be better off just counting logins in /etc/profile. Put something like this at the beginning on /etc/profile:

QTY=$(who | wc -l)
if [ $QTY -gt 100 -a $(id -u) -gt 0 ]
then
echo "\n\nSorry, no more connections allowed\n"
sleep 3
exit
fi

The above code is simpler than changing the kernel parameters and will not affect other service connections. Note that this counts every session even if the same user has logged in several times.


Bill Hassell, sysadmin