H.2. Preventing Users from Logging onto Several Thin Clients Simultaneously

This can be a real problem when a user logs onto several thin clients at the same time, for example if he tries to change the background picture in both places.

The solution is to set up a little test when a user logs on, to check if he is already logged on. If he is, then he is prevented from logging on again.

The script that makes this possible, or rather makes it impossible for one user to log on to several thin clients simultaneously is found in the file /etc/X11/Xsession.d/10skolelinux-one-login-per-host. YOu will also find instructions there as to how this script should be started. It is started by creating a so-called "flag file" with the command

tjener:~# touch /etc/skolelinux/limit-logins

This is the contents of the file that does the job of preventing one user from logging on to several thin clients simultaneously.

more /etc/X11/Xsession.d/10skolelinux-one-login-per-host

# Make sure a given user do not log into the same computer twice.
# When this is done on an LTSP server, the KDE configuration is likely
# to be destroyed.

# debug=1
log() {
    if [ "$debug" ] ; then
        echo "$@"

    # Do not try to limit the root user
    if [ "$u" != "root" ] ; then
        num=`who | cut -d" " -f1 | grep "^$LOGNAME\$" | wc -l`

    log "Found $num connections for user $LOGNAME"

    if [ "$num" -gt 1 ] ; then
        numps=`ps -eu "$LOGNAME" | grep -v -e sleep -e COMMAND|wc -l`
        num=`expr $numps + 1`

    if [ $num -gt 1 ] ; then
        xmessage -buttons greit:0 -timeout 30 -center \
            "You are NOT permitted to log on to more than one machine at the same time!"
        exit 1

# Only enable this if the flag file exists.  When the code is tested
# and found to work fine, we can enable it for everyone. [pere 2003-02-21]
# To enable this script you must create an empty file with the command
# touch /etc/skolelinux/limit-logins
# [klaus 2003-09-06]

if [ -f /etc/skolelinux/limit-logins ] ; then

H.2.1. Kicking Out a User

Sometimes it is necessary to kick a user out. This is the little script that takes care of that.

# Saved as for example
#Remember chmod 755 /usr/local/bin/ut
#Used in this way
#'ut username'
# script to kick out a user

if [ $1 != "root" ]
for i in $(pgrep -u $1)
kill -9 $i
echo "Cannot kick out root."

The script is used in this way, to kick out the user named klaus,

ut klaus