only one user logged per session/time

Lanny Godsey lannygodsey at
Thu Sep 11 12:52:44 PDT 2003

(my first reply was direct and not to list, someone else may use this

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


place the following into /usr/local/bin/onelogin
# set the limit here.
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
# 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
# set the shell you want here


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 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