Setup guest account

The role ufrmath.computer_labs.setup_guest is used to add guest user in GDM by creating password less guest user and adding scripts to wipe the corresponding home directory. The SSH login for guest user is disabled.

First, a standard guest account with disabled password has to be created with:

sudo adduser --disabled-password guest

and then to delete the password (make it empty):

sudo passwd -d guest

To prevent guest user from modifying its password:

sudo passwd -n 99999 guest

Finally, the following scripts are used to wipe the guest home directory:

#!/bin/sh
if [ "$USER" = "guest" ]
then
   rm -rf /home/guest
   # copy files from skel
   cp -r /etc/skel /home/guest
   chown -R guest:guest /home/guest
else
   # copy files from skel (if do not exist)
   sudo -u "$USER" cp -rn /etc/skel/. "$HOME"
fi
# create defaults dirs
sudo -u "$USER" xdg-user-dirs-update
# remove empty default directories
rmdir "$HOME/Documents" "$HOME/Images" "$HOME/Modèles" "$HOME/Musique" "$HOME/Public" "$HOME/Vidéos"
exit 0
#!/bin/sh
if [ "$USER" = "guest" ]; then
   rm -rf /home/guest
fi
exit 0
Previous
Next