How do I set a password for guest login? [duplicate]

I'd like to set a password for the guest account. How can I do this? (This question is not answered under the similar question in this forum, see below.)

The last time this was asked on this forum it was suggested that there was no reason to set a password on guest as it was equivalent to set up a new, regular account with a password. It seems to me that this is not the same thing. The guest account is secure by default, limits access to the file system and is self-cleaning, regular accounts are not. By self-cleaning I mean that it leaves no loose files, no internet history, no potential viruses (I know, Linux has none), etc. since it all takes place in temporary space.

It is good to have the guest account protected, too, in some situations. For example, if you live in a group house and have a common computer you may want to share freely with people you know but otherwise limit expensive internet access. Not everyone has the same situation.

One suggestion last time was to "Open a terminal ... Then type passwd and the user name. So it should be passwd guest" This didn't work in my hands, even with sudo. Linux replied "user 'guest' does not exist" Am I doing something wrong?

If Ubuntu is not designed to allow a password on the guest account then, in the spirit of Linux, if you think this is a reasonable thing to do, let's look for a workaround.

Anyone?

(I'm a newbie, so let me know where I'm being naive.)


The Guest Account exists as a created-then-destroyed-on-logout account that is limited in what it can do and exists without a password. That is the purpose of a "guest account" - limited access, automatically-destroyed-on-logout. It is not designed to run with a password.

You can create a "guest" account that you can keep as a normal user (not a guest user) by making a user named "guest" and setting a password on that, though, and then potentially restricting their access. You can then disable the normal "guest account". (The guest account system however will never have a password.)


One suggestion last time was to "Open a terminal ... Then type passwd and the user name. So it should be passwd guest" This didn't work in my hands, even with sudo. Linux replied "user 'guest' does not exist" Am I doing something wrong?

That is because the guest user is only present when the guest account is used. It is created when you login as guest and it is deleted when you logout.

As others said, the guest account cannot be made easily password protected. To see why, just open the /usr/sbin/guest-account script. This is the script which is used for setting up or removing the guest account on login/logout. It contains the following code:

if PWSTAT=`passwd -S "$USER"` 2>/dev/null; then
if [ "`echo \"$PWSTAT\" | cut -f2 -d\ `" != "L" ]; then
  echo "User account $USER already exists and is not locked"
  exit 1
fi

The above snippet shows that before the script sets up the guest environment it checks whether there is a user named guest in the system. If it finds such a user it checks whether it has a locked account. If it doesn't have a locked account then the script exits with error and the guest login will fail. So even if you decide to make a permanent guest user and setup a password for him, you will fail, because it won't have a locked account.

What you can do is to investigate the script to know what is done in the setup and in the cleanup. Add a guest user to your system with a password. Write a script which mimics the guest-account script in the way you like. Then just use the /etc/lightdm/lightdm.conf file's session-startup-script and session-cleanup-script sections to specify your newly written script as the script which should run for this guest user. (for instructions with the lightdm.conf file look here ). But note that lightdm has a bug (?) and because of that the session-cleanup script fails to run when you directly shutdown from the account, so the guest should always log-out before shutdown.