1838134 Members
4452 Online
110124 Solutions
New Discussion

how can I limit telnet

 
SOLVED
Go to solution
Fred.Wu
Frequent Advisor

how can I limit telnet

How can I limit telnets to a number?
For example,I need the system allow less than 5 telnets, any more will be refused.
What should I do then?

fred
4 REPLIES 4
KCS_1
Respected Contributor

Re: how can I limit telnet

Hi,

You can use under shell script for limit a number of users on your system.

# Limit number of logins alowed
Times_allowed=4
Time_in=`who | grep $LOGNAME | wc -l`
if [ $Time_in -gt "$Times_allowed" ]
then
echo "$LOGNAME is already logged in $Times_allowed times!"
exit
exec /bin/login
fi






Easy going at all.
Stefan Farrelly
Honored Contributor
Solution

Re: how can I limit telnet

You can simply remove or rename the /dev/pts telnet tty files - leave as many as you want to restrict telent sessions. If you later want to enable a few more put some /dev/pts entries back - simple and easy!

cd /dev/pts
lssf * | grep tels | wc -l

This totals the number of telnet device files (logins) allowed. Simply move out of this dir (to say a temporary dir in case you want them back later or else you will have to run insf) those you dont want leaving say 5 which limits telnet logins to 5 for the server.

Im from Palmerston North, New Zealand, but somehow ended up in London...
Ravi_8
Honored Contributor

Re: how can I limit telnet

Hi,

kernel parameter nstrtel decides the no. of telnet sessions. usually it w'll be set to 60. reduce it to 5 and build the kernel
never give up
Jose Mosquera
Honored Contributor

Re: how can I limit telnet

Hi,

If you are referring to users' concurrent accesses pls take note:

On 10.20 is a hard task, on 11.0 you onlys need define in /etc/default/security file:
NUMBER_OF_LOGINS_ALLOWED=3 (must be in caps)
This apply for no-root users (su excluded)

And certify that PHCO_27721 patch is installed. Look a symtom solved by this patch:

When the maximum number of logins to the system allowed for each user is specified by the NUMBER_OF_LOGINS_ALLOWED field in the /etc/default/security file, users whose names are longer than 4 bytes are treated as the same user if the first 4 bytes of the user names are identical.


Other way could be include in /etc/profile file followings lines:

MAX=3
CURRENT=`who|grep $LOGNAME|wc -l`
if [ $CURRENT -gt $MAX ]
then
exit
fi

Rgds.