The objective is to create a passwordless login for a user named guest, whose home directory is cleared on logout.
This was tested under KDE neon (which is based on Ubuntu 16.04).
The following script clears the home directory of a user and replaces it with a tmpfs containing the contents of /etc/skel
:
#!/bin/sh -e
# Copyright 2017 Michel Zimmer <[email protected]>
# License: MIT
U="${1}"
id --user "${U}" >/dev/null 2>&1 || { echo 'Usage: tmpfsify-home USER'; echo "User ${U} not found!"; exit 1; }
[ "$( id --user ${U} )" -lt 1000 ] && { echo 'Not going to tmpfsify a system user!'; exit 1; }
[ "${U}" = "${USER}" ] && { echo 'Not going to tmpfsifying yourself!'; exit 1; }
H="$( getent passwd ${U} | cut -d: -f6 )"
[ -e "${H}" ] && { umount "${H}" || rm --recursive --force "${H:?}/*"; }
mkdir --parents "${H}"
mount --types tmpfs --options mode=700 none "${H}"
cp --recursive --no-target-directory '/etc/skel' "${H}"
chown --recursive "${U}:" "${H}"
- Place the script at
/usr/local/sbin/tmpfsify-home
and make it executable for the root user. - Create the guest user:
sudo useradd --comment 'Guest,,,' --no-create-home guest
- Set passwordless login:
echo 'guest:U6aMy0wojraho' | sudo chpasswd --encrypted
- Hook to sddm for auto cleanup:
echo '[ -x /usr/local/sbin/tmpfsify-home ] && /usr/local/sbin/tmpfsify-home guest' | sudo tee --append /usr/share/sddm/scripts/Xsetup
- Cleanup once:
sudo tmpfsify-home guest
Now that Linux is transitioning to Wayland it would be nice to have this script updated :)
I tried to hook to sddm Wayland session for auto cleanup:
echo '[ -x /usr/local/sbin/tmpfsify-home ] && /usr/local/sbin/tmpfsify-home guest' | sudo tee --append /etc/sddm/wayland-session
but it doesn't work.
Do you have any idea how to do it properly?