only one user logged per session/time
Lanny Godsey
lannygodsey at yahoo.com
Thu Sep 11 12:52:44 PDT 2003
(my first reply was direct and not to list, someone else may use this
also)
This isn't exactly what you want, but you may want to look at
/etc/login.conf and limit the # of processes, memory, and files a user
may have open.
add the following to /etc/login.conf, then run cap_mkdb /etc/login.conf
onelogin:\
:tc=default:\
:shell=/usr/local/bin/onelogin:
place the following into /usr/local/bin/onelogin
------------------------------------------------------
#!/bin/sh
# set the limit here.
CNT=1
MYUID=`id -u`
DEVS=`find /dev -user $MYUID | wc -l`
if [ $DEVS -gt $CNT ]; then
echo Sorry, this system has limited you to only $CNT simultanious
connections.
exit
fi
# read users shell from passwd (this won't work with nis)
MYSHELL=`grep ^$USER: /etc/passwd | cut -d : -f 7`
# some /bin/sh variants may not allow to write to $SHELL
SHELL=$MYSHELL
# set the shell you want here
exec $MYSHELL
-----------------------------------------------------------------
pw usermod james -L onelogin
now james should be limited to 1 login.
you can also change CNT=2 to limit to 2 etc...
I just wrote this when I got your email so be sure to test first, if
you have any questions let me know.
--- nbari at unixmexico.com wrote:
> Hello, I have a server with ssh access to the users, but how can I
> allow
> only one user to be logged at a time.
>
> I dont want to allow a user to login multiple times, I just want the
> user
> to login onece and if he try to open a second coneection, refuse the
> user
> until the session is over or the user is allready loged.
>
>
> thanks in advance.
More information about the freebsd-isp
mailing list