I have a special lab machine (linux) and two different users will be using this machine. They need to log in with the same userid. I want to prevent both of them from logging in at the same time. How can I do that?
I was thinking of starting with something simple like this - Use the users source IP-address and add some checks in .bashrc
:
If a user logs in from IPAddress1 and there is already somebody ssh'ed in from IPAddress2 then print a big fat message.
You can use pam_limits to do this too. Add a line like
to
/etc/security/limits.conf
and it will only allow the userfred
to log in up to 1 (maxlogins) times.I think your plan sounds reasonable. Maybe do a check against something like
last [username] | grep "still logged in" | wc -l
in bashrc ? - could check for the ip there, also.