Limit the Number of Telnet Sessions a user can open?

Limit the Number of Telnet Sessions a user can open?

Post by Marc Spitz » Wed, 22 Mar 2000 04:00:00




> I have a problem with one of my users on a Sun Solaris 2.6 system.
>The users access an informix data warehouse via a telnet application.
>Some of my users want to open up a dozen sessions at once, and one
>user in particular routinely has 25 or 30 telnet sessions active. This
>leads to many problems including performance issues, orphaned
>processes, etc. Is there a way to limit the number of telnet sessions
>a single user (or all users) can have open concurrently?

>JT

Look at xinetd, dont have the url handy bit I think it is on yahoo.

marc

 
 
 

Limit the Number of Telnet Sessions a user can open?

Post by Mike Purdi » Thu, 23 Mar 2000 04:00:00


One simple way is to write a script that simply checks how many times the
user is logged in and logs them out if they are trying to log in too many
times. Put the script in the relevant shell startup file (.profile for
sh/ksh/bash, .login for csh). Try something like this:

#!/bin/ksh
whoami=`whoami`
login_count=`w | grep $whoami | wc -l`

if [ $login_count -gt 10 ]
then
    logout
fi

Create this and put it somewhere like /usr/local/bin, then simply call it
from the relevant login script:

csh:
source /usr/local/bin/script_name

ksh/bash/sh:
. /usr/local/bin/script_name

Depending on what version of Unix you use, you may have to change the
commands:

w            : list whos on
whoami : tell you who you are
wc  -l      :  line count

Cheers

Mike Purdie


> I have a problem with one of my users on a Sun Solaris 2.6 system.
>The users access an informix data warehouse via a telnet application.
>Some of my users want to open up a dozen sessions at once, and one
>user in particular routinely has 25 or 30 telnet sessions active. This
>leads to many problems including performance issues, orphaned
>processes, etc. Is there a way to limit the number of telnet sessions
>a single user (or all users) can have open concurrently?

>JT


 
 
 

Limit the Number of Telnet Sessions a user can open?

Post by Ryan A. Krenzische » Thu, 23 Mar 2000 04:00:00



> One simple way is to write a script

We'll depending on how heavy of a system load, the script may
reduce system performance because it has to do one extra thing
when logging on.  The best way to take care of this problem is
to set environment variables for the kernel.

Since this question has come up in comp.unix.solaris before, I have
included
two fixes for similar questions that address:

        o expand or limit the number of pseudo-ttys (which in turn limits the
          number of maximum telnet sessions open on a system)

        o limit the user's processes to xxx (listed after the 3.41 entry below)

For example on solaris 2.x, you can limit the number of pseudo ttys
which would in turn limit the number of users that could login.  The
following
specifies how to allocate more than 48 pseudo-ttys, but lowering the
number
would reduce the number of pseudo-ttys.

The solaris FAQ says:

3.41) How can I have more than 48 pseudo-ttys?

    Edit /etc/system and add the following line:

        * System V pseudo terminals

        set pt_cnt = <num>

    Halt the system and boot -r.

    You can essentially have as many as you like, but you'll probably
    run into some other limit somewhere.  More than 3000 are supported.
    Solaris 2.6 and earlier have telnet/rlogin daemons that do not
    support more than 3844 sessions each.  That restriction is lifted
    in Solaris 7.

    Some die-hard system administrator myths as well as some Sun
    documentation claim that you have to increased "sad_cnt", "sadcnt"
    or "nautopush" when adding ptys.  There is no truth in this.

    In the unlikely event that you run out of BSD-style ptys,
    you can increase them as well.  The maximum here is currently
    176 for pty[p-z][0-9a-f].  This is somewhat less that the BSD
    maximum of 256 limited by 8 bit device minor numbers.

    BSD ttys are awkward to use and all programs I found support SYSV
    ptys without trouble.

        * You don't need this.  Increasing this value too much usually
        * just wastes memory.
        * BSD applications never support more than 256 ptys.
        * Solaris 2.x supports no more than 176 BSD ptys.

        set npty = <num>

    But you're not there yet, you also need to edit /etc/iu.ap and
    substitute the new value of "npty-1" for the "47" on the following
        set npty = <num>

    But you're not there yet, you also need to edit /etc/iu.ap and
    substitute the new value of "npty-1" for the "47" on the following
    line, in case you do increase the number of BSD style ptys.

                ptsl    0       47      ldterm ttcompat

    Halt the system and boot -r.

    --- end of excerpt from the FAQ

Questions marked with a * or + have been changed or added since
the FAQ was last posted

The most recently posted version of the FAQ is available from
<http://www.wins.uva.nl/pub/solaris/solaris2/>

If you are interested in limiting the number of maximum sessions that
a user can have, instead of writing a script that could slow down your
system under heavy-loads or extend login time, use maxuprc (under
solaris).

Is there a Solaris 2.4 kernel tuning parameter that stop unfriendly
programs from taking over a system?
Q: Is there a Solaris 2.4 kernel tuning parameter (like maxuprc) that
would allow sysadmins to stop unfriendly programs from taking over a
system?
The problem we have sometimes seen is a poorly written program forking
off infinite copies of itself until the machine dies or hits its process
limit. We
want to be able to limit a user's total to, say, 100 processes.

Is this possible under Solaris 2.4?
--Lance Nakata, Stanford University

A: The same maxuprc variable does this for you in Solaris 2.X

set maxuprc=100 in /etc/system and reboot

(From http://www.sunworld.com/common/cockcroft.letters.html)

Cheers!

rk