Skip to content

Instantly share code, notes, and snippets.

@michel-zimmer
Last active December 21, 2021 19:45
Show Gist options
  • Save michel-zimmer/d0643cf432addb64e92a3e631f6c9392 to your computer and use it in GitHub Desktop.
Save michel-zimmer/d0643cf432addb64e92a3e631f6c9392 to your computer and use it in GitHub Desktop.
Add a guest for sddm (tested under KDE neon)

Add a guest user for sddm

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 <mzimmer@uni-bremen.de>
# 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}"
  1. Place the script at /usr/local/sbin/tmpfsify-home and make it executable for the root user.
  2. Create the guest user: sudo useradd --comment 'Guest,,,' --no-create-home guest
  3. Set passwordless login: echo 'guest:U6aMy0wojraho' | sudo chpasswd --encrypted
  4. 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
  5. Cleanup once: sudo tmpfsify-home guest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment