The reason I want to kill the old connection and allow the new one is because the server only provides a secure tunnel, nothing else. I want to eliminate the situation which will arise when the user forgetfully leaves it logged in in at home, and now they can't log in from elsewhere.
I've already managed to limit max number of concurrent logins. Is there a way to actually process output of 'w' or 'who' or 'ps x | grep ssh' or somesuch to disconnect the old / both users?
I just want the thing to DC so the user does not have to actually close the old session in order to get into the server again, while at the same time, the user cannot be logged in twice.
Edit: I think this is the best way to do it:
$ ps x | grep 'sshd:'
24526 ? Ss 0:01 sshd: root@pts/3
25723 ? Ss 0:00 sshd: breakaway [priv]
25754 ? Ss 0:00 sshd: vent [priv]
25846 ? Ss 0:00 sshd: devon [priv]
25941 ? Ss 0:00 sshd: breakaway [priv]
26016 pts/3 R+ 0:00 grep sshd:
Now to figure out how to use 'tr' to get only the PID and the usernames out and process them, and then kill them both.
Edit 2: figured out how to use 'tr' and 'cut' to get only what I want out of the output:
$ ps x | grep priv | tr -s " " | cut -f 1,6 -d ' '
Obviously the last one (26617 priv) can be ignored as it is just grep printing itself.
Now to somehow compare each value (usernames) to every otehr value in order to see if there are any matches. If there are, then pass their PIDs to the 'kill' command.