129

If I attempt to change my password to nothing by opening "User Accounts", the "Change" button remains greyed out:

How do I change my password to be empty? I know you can set Ubuntu to automatically log you in, but I want my password to be empty, I never want to type in a password to authenticate myself as that user.

I know that there are reasons why this might not be a good idea, but I want to know if it is even possible. I'm using Ubuntu 12.10.

Organic Marble
  • 23,641
  • 15
  • 70
  • 122
Flimm
  • 41,766
  • 1
    Why on earth did you accept an incorrect answer that locks you out of your account??? – Kaz Mar 20 '21 at 14:57
  • @Kaz It doesn't if you follow all the steps in the answer, including the step that was linked to at the end. – Flimm Mar 21 '21 at 06:41

6 Answers6

213

You can't do that using the GUI tool, but you can using the terminal.

  1. First, if your user has sudo privileges, you must enable its NOPASSWD option. Otherwise, sudo will ask for a password even when you don't have one, and won't accept an empty password.

    To do so, open the sudoers configuration file with sudo visudo, and add the following line to the file, replacing david with your username:

    david ALL=(ALL) NOPASSWD:ALL
    

    Close the editor to apply the changes, and test the effect on sudo in a new terminal.

  2. Delete the password for your user by running this command:

     sudo passwd -d `whoami`
    
  3. Follow the steps in this answer in order to make pkexec accept a user with no password. pkexec is used by some applications when root privileges are required.

If you ever get prompted for a password, just type enter and it should work. I've tested this answer with LightDM, the lock screen, sudo, gksu, and it works.

Flimm
  • 41,766
  • 1
    For pkexec, see http://askubuntu.com/a/614537/158442 – muru Sep 17 '15 at 23:09
  • 2
    Any new visudo edits such as nopasswd should be added to the end so no other setting overwrites the entry. – Dean Meehan May 23 '16 at 07:55
  • 9
    This did not work for me (Ubuntu 16.04) via ssh login. It still asks for a password, but no password is accepted (blank or the old one or the one for the ssh key). – CoderGuy123 Aug 07 '16 at 20:44
  • @Deleet For SSH I would always recommend using SSH keys and disabling username+password authentication altogether. – Flimm Aug 10 '16 at 12:12
  • 3
    On Debian I got the message "Sorry that didn't work try again" when I try to log with empty password after the command passwd david -d. And now I can't login with the old password too. – fabriciorissetto Nov 10 '16 at 22:42
  • @fabriciorissetto: If this happens you can just run passwd david to set a new password for yourself. – D Schlachter Sep 28 '17 at 00:57
  • I've tried to do that and got my visudo broke. Now for some reason I've being asked for a password by ubuntu user, which I don't have to execute sudo commands and didn't need either before. #sad – Leo Ribeiro Mar 28 '18 at 02:12
  • 3
    Now I can't install software as it requires a password to do so. – Matthew Jan 14 '19 at 16:31
  • 1
    According to this answer, deleting password is generally a bad idea since it allows log in without password (the password login may be disabled for SSH but there may be other services which may accept it). You should create a user with a disabled password instead. – David Ferenczy Rogožan Mar 05 '20 at 12:07
  • It doesn't seem to work for Ubuntu Server 20.04. – Yan Yang Jul 03 '20 at 07:34
  • This answer is incorrect. The question asks how to set an empty password (the password is he hash of the empty string). passwd -d sets the password field in /etc/shadow to be empty, which means that the account has no password. – Kaz Mar 20 '21 at 14:55
  • @Kaz The question title is: "Can I set my user account to have no password?" I didn't see a distinction between a hash of an empty password and an empty entry in /etc/shadow. If there is a meaningful distinction, please post an answer about that. – Flimm Mar 21 '21 at 06:43
  • @Flimm I believe I'm not saying anything controversial in the following remark, which is that answers are supposed to address the content of the question, rather than react to the title. The question says "I never want to type in a password to authenticate myself as that user". After sudo passwd -d, authenticating isn't possible, regardless of what password is tried. – Kaz Mar 21 '21 at 14:48
  • @Kaz That's weird. It should be passible by just pressing enter. It's been a while since I've tried it. – Flimm Mar 21 '21 at 15:52
  • well really great. now when I try to install or uninstall software in the "Software" application it prompts me for a password and just entering nothing doesn't work and the old password obviously also doesn't work anymore. – user3700562 Oct 17 '21 at 11:14
  • @user3700562 Did you follow the additional step for pkexec? – Flimm Oct 18 '21 at 08:22
  • @Flimm Can you then revert the command "sudo passwd -d whoami"? I have already deleted the line david ALL=(ALL) NOPASSWD:ALL. Basically, how can I add the password back into the user account? – John Carter Mar 20 '24 at 15:53
19

Warning: Be careful once you remove your password using this method, you won't be able to authenticate yourself to prove you have admin rights, in a GUI or in the terminal (like installing an application using Synaptic, or using sudo through the command-line). This is because of bug #1168749.

Only do this if the user is not the only admin user.

This has been tested on Ubuntu 12.04 and 12.10.

  1. Make sure that you click on Unlock to be able to accomplish the tasks below:

    Unlock screenshot

  2. Go into user accounts, and click on the password field:

  3. Once the window opens, click on the down arrow to the right of "Action"...

  4. and change it to "Log in without a password", and then click on "Change":

  5. Optionally, you can also enable automatic log-in, like this:

    Screenshot

To give the user a password again after running this procedure, you can't use a GUI (bug #882255), you have to use the command-line:

  1. Log in as another user with admin priveleges. (Remember, the original one cannot run with admin privileges without a password using this method.)

  2. Run the following in a terminal:

     sudo passwd <username>
    

Again, I must warn you that once you remove the password, you won't be able to authenticate yourself in the GUI or a terminal, like installing an application using Synaptic, or using sudo on the command-line.

Mitch
  • 107,631
  • I have a question though, what does the option "Log in without a password" actually do? Does it basically do passwd -d and deletes the password? – Alaa Ali Sep 22 '13 at 15:25
  • Well I honestly not a 100% sure. But passwd -d is a quick way to delete a password for an account. It will set the named account passwordless. Available to root only. – Mitch Sep 23 '13 at 06:18
  • Available to root only? No man, you can use it to delete any user's password =). I think this is what the "Log in without a password" option actually does; it just deletes your password, that's why you won't be able to authenticate yourself. That's just stupid though. – Alaa Ali Sep 23 '13 at 06:25
  • 1
    I agree, but just to give you an example, I have a shared laptop, that sometimes my kids use, and they restart it about a million times an hour, and I don't have time to keep typing the password every time, so I set the account to automatic login, to save myself the hassle, and so they can't miss anything up more than what they already do. :) – Mitch Sep 23 '13 at 06:34
9

I think it's possible to do this, but will get you into trouble once you try to install updates or anything else that requires sudo; as you need an account with sudo access (and a password) in order to install.

Your best options seem to be:

  • Use the Guest account that doesn't have a password. Thereby leaving a default account with password.
  • Hellbent on an account without password? Strongly recommend not doing this: Add a new user account (with password), then change it to be the equivalent as blank. To do this:
    1. create a user (either via GUI or useradd, etc). Then,
    2. CTRL-ALT-T to open terminal. Next,
    3. gksu gedit nano -B /etc/shadow then find the new user and change the existing password hash with: U6aMy0wojraho -- so it looks something like: newuser:U6aMy0wojraho:13996:0:99999:7:::
  • Best solution to your question: Choose to automatically log in your account, which is likely the main benefit you're after. to do this:

    1. press CTRL-ALT-T (to open terminal). In Terminal, type:

      sudo gedit /etc/lightdm/lightdm.conf
      

      add the lines:

      autologin-user=YOURUSERNAME
      autologin-user-timeout=0
      

      replace YOURUSERNAME -- with an actual username on your system.

muru
  • 197,895
  • 55
  • 485
  • 740
  • Thanks for pointing out the alternatives. I know that having no password is not a great idea, but I want to know if it is possible (I've updated the question). – Flimm Apr 13 '13 at 17:55
4

Looks like, an empty password doesnt match Password Complexity requirements.

This is what I found in man passwd

As a general guideline, passwords should consist of 6 to 8 characters including one or
       more characters from each of the following sets:

       ·   lower case alphabetics

       ·   digits 0 thru 9

       ·   punctuation marks

       Care must be taken not to include the system default erase or kill characters.  passwd will reject any password which is not
       suitably complex.

EDIT: Unfortunately, you can't set the password to empty through that UI.

http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/quantal/gnome-control-center/quantal-proposed/view/head:/panels/user-accounts/um-password-dialog.c#L358

is the function which decides whether to enable the "Change" button or not.

    if (strlen (password) < MIN_PASSWORD_LEN) {
            can_change = FALSE;
            if (password[0] == '\0') {
                    tooltip = _("You need to enter a new password");
            }
            else {
                    tooltip = _("The new password is too short");
            }
    }
    else if (strcmp (password, verify) != 0) {
            can_change = FALSE;
            if (verify[0] == '\0') {
                    tooltip = _("You need to confirm the password");
            }
            else {
                    tooltip = _("The passwords do not match");
            }
    }
    else if (!um->old_password_ok) {
            can_change = FALSE;
            if (old_password[0] == '\0') {
                    tooltip = _("You need to enter your current password");
            }
            else {
                    tooltip = _("The current password is not correct");
            }
    }
    else {
            can_change = TRUE;
            tooltip = NULL;
    }

    gtk_widget_set_sensitive (um->ok_button, can_change);

The minimum password len 6 is hardcoded :(

http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/quantal/gnome-control-center/quantal-proposed/view/head:/panels/user-accounts/um-password-dialog.c#L39

#define MIN_PASSWORD_LEN 6
thefourtheye
  • 4,924
  • 1
    It's "more what you'd call guidelines than actual rules"... – Oli Apr 13 '13 at 17:30
  • But the last line says, "passwd will reject any password which is not suitably complex.". So, it wouldnt possibly allow an empty password, I believe. – thefourtheye Apr 13 '13 at 17:32
  • But again, those items there are not the requirements. You don't need the full spectrum of character and case, they're just suggesting you use them for a stronger password. PAM looks after the rules on what you actually need. – Oli Apr 13 '13 at 17:45
  • 3
    You can set an empty password with passwd with the -d option. – Flimm Apr 13 '13 at 19:12
  • Yup. Read it in man pages. Thats why I said "can't set the password to empty through that UI." – thefourtheye Apr 13 '13 at 19:17
4

Its a GUI interface and that is what is preventing you from making it a blank password.

If there was a way it would have to be done via terminal.

But, in the end you have to enter the system via the GUI and even if you did change the password to blank the GUI would prevent that. So unless you want to change to a non GUI interface it is simply not possible.

Meer Borg
  • 4,963
2

It is possible to change password after deletion. You need just to boot in recovery mode. Here you'll find a nice tutorial: http://www.psychocats.net/ubuntu/resetpassword

In short what you'll find on the link above:

  1. you have to reboot into recovery mode. (to get the boot menu to show, you have to hold down the Shift key during bootup)
  2. In boot-up menu select "Drop to root shell prompt" option

  3. type on console one by one

    ls /home
    passwd username
    passwd susan
    exit
    

    then reboot normal

muru
  • 197,895
  • 55
  • 485
  • 740
larshaeuser
  • 121
  • 2
  • 1
    Please consider editing your answer to include at least an outline of what's described in the article you're linking and provide the link for reference/attribution purposes. This way if the link becomes unavailable for whatever reason, your answer will remain helpful. – hmayag Jun 19 '14 at 10:14