Operating System - HP-UX
1836372 Members
2346 Online
110100 Solutions
New Discussion

Re: modify number of telnet sessions

 
SOLVED
Go to solution
Dave Bunting
Frequent Advisor

modify number of telnet sessions

Hi,
how do i limit telnet sessions to specific users? for example, i want usera to only be allowed 3 telnet sessions, the other only 1 or 2, is that possible? or is it a universal (sort of) parameter that when you set it, everybody will be affected?
Thanks
8 REPLIES 8
harry d brown jr
Honored Contributor

Re: modify number of telnet sessions

The only way to do such is to write a script that will check the number of telnets at login time. If the have three already, then give them a warning message and log them off. The same goes for who can use telnet.

live free or die
harry
Live Free or Die
Dave Bunting
Frequent Advisor

Re: modify number of telnet sessions

uh-oh...can you give me a sample script pleaseeeeeeeeee??? i'm not that familiar into scripting... sorry...
harry d brown jr
Honored Contributor

Re: modify number of telnet sessions

Michael Tully
Honored Contributor

Re: modify number of telnet sessions

Hi,

That is correct you would have to write a script or modify something like /etc/profile.
You could put these people into
separate groups that could comprise of one, two
or three users. The below is a sample of what
you could do wiuth /etc/profile.

# Restrict 'root' direct login to 'console' only
RealName=`who am i|cut -f1 -d\ `
case $RealName in
root) WHERE=Y ;;
ingres) WHERE=Y ;;
dba) WHERE=Y ;;
xcom) WHERE=Y ;;
*) WHERE=N ;;
esac

if [ "$WHERE" = "Y" -a "`tty`" != "/dev/console" ]; then
echo "\n\tYou MUST login under your own ID first.....bye^G^G^G"
exit 1
fi
unset RealName WHERE

Also have a look at this link, you will find it interesting.

http://forums.itrc.hp.com/cm/QuestionAnswer/1,11866,0x5e06670142b2d5118ff10090279cd0f9,00.html

-Michael
Anyone for a Mutiny ?
harry d brown jr
Honored Contributor

Re: modify number of telnet sessions

Or maybe with tcp wrappers?

http://www.itso.iu.edu/howto/tcpwrap-unix.epl

live free or die
harry
Live Free or Die
Dave Bunting
Frequent Advisor

Re: modify number of telnet sessions

hi again script savvy guys...
can you please provide me sample script where i can restrict a certain user to only telnet a number of times? lets say i will only allow userA to have a max number of 5 telnet sessions.. can that be done?
Thanks again...
sorry, im not that familiar with scripting...
:-(
harry d brown jr
Honored Contributor

Re: modify number of telnet sessions

Dave,

if someone hasn't down it by tomorrow morning (monday my time EST), I'll whip one up.

What version of HPux do you have, and do you have "perl" installed?

thanks,

live free or die
harry
Live Free or Die
Michael Tully
Honored Contributor
Solution

Re: modify number of telnet sessions

Hi,

Hi Another way to do this would be to call
another script that evaluates the
user profile before actually runnning it.
Here is a sample, that I had where /etc/profile
calls this script, 'eval_class.ksh'


function multiLogins # allow/disallow
{
typeset Flag=$1 ttyID
#
# Display login information
if [ "$(who |grep -c $LOGNAME)" -gt 1 ]; then
typeset ttyID="$(who -R |awk -v user="$LOGNAME" '{if($1 == user){ printf "Terminal: %s from location: %s\n ",$2,$6}}')"
clear
print "\n\t You are Currently logged in on the following terminals:"
print " -------------------------------------------------------"
print " $ttyID \n"
sleep 5
#
if [ "$Flag" = "disallow" ]; then
print "\n Contact your Supervisor "
print " You will now be logged out"
sleep 5
exit
fi
fi

}

# test for batch mode login
if tty -s; then
# test and set the type of terminal used
#
MYCLASS=GENERAL
eval $(grep 'MYCLASS=' $HOME/.profile 2>/dev/null)
export MYCLASS

#
# check if multiple logins are permitted
#
case ${MYCLASS} in
GENERAL) multiLogins disallow ;;
SUPERV*) multiLogins allow ;;
ADMIN) multiLogins allow ;;
esac
#
fi
#
unset checkFlag TTYTYPE

HTH
-Michael
Anyone for a Mutiny ?