It turns out it's quite simple with GDM. I assume you're using GDM since you're also using Gnome. First, create the guest user account with a blank password:
sudo useradd -d /tmp/guest -p $(openssl passwd "") guest
The openssl passwd "" will return the hash of the empty string, thereby setting the password to blank.
Now, all you need are these two scripts:
/etc/gdm/PostLogin/Default
This is executed after you log in and will create the /tmp/$guestuser (/tmp/guest by default) directory and copy the default files from /etc/skel to it. To change the default username for the guest user, set guestuser to something else at the beginning.
<!-- language: lang-bash -->
#!/bin/sh
guestuser="guest"
## Set up guest user session
if [ "$USER" = "$guestuser" ]; then
mkdir /tmp/"$guestuser"
cp /etc/skel/.* /tmp/"$guestuser"
chown -R "$guestuser":"$guestuser" /tmp/"$guestuser"
fi
exit 0
/etc/gdm/PostSession/Default
This is executed after you log out and will remove the /etc/$guestuser directory and all its contents. Make sure to set guestuser to the same value in both scripts.
<!-- language: lang-bash -->
#!/bin/sh
guestuser="guest"
## Clear up the guest user session
if [ "$USER" = "$guestuser" ]; then
rm -rf /tmp/"$guestuser"
fi
exit 0
Finally, make the two scripts executable:
sudo chmod 755 /etc/gdm/PostLogin/Default /etc/gdm/PostSession/Default
Now, just log out and you will see your new guest user. You can log in by selecting it and hitting Enter when prompted for a password. The guest user won't be able to use sudo since that is the default for all users anyway. Only users explicitly mentioned in /etc/sudoers or those who are members of groups explicitly mentioned in sudoers (such as wheel or sudo, depending on your distribution) can use sudo.
If you are using a recent version of GDM, it may disable the login button while the password box is empty. To work around this you can tell GDM not to prompt for the password for specific groups. The caveat is that this will also bypass the session selection menu for members of that group. If you want to do this you should add this line at the beginning of /etc/pam.d/gdm-password:
auth sufficient pam_succeed_if.so user ingroup guest