How do you create a user with no password?
Solution 1
You can run passwd --delete <username>
after creating the user with adduser
. After this, you'll be able to login without entering a password.
Solution 2
You can use usermod
, which will disable the password using an !
rather than an *
.
usermod -L <username>
From the man page on usermod:
-L, --lock Lock a user's password. This puts a '!' in front of the encrypted password, effectively disabling the password.
Solution 3
A user in /etc/passwd with home directory of /dev/null and shell of /sbin/nologin, can be used for sudo ing commands, but can't actually be logged into, for example;
from my /etc/passwd
tcpdump:x:104:441:added by portage for tcpdump:/dev/null:/sbin/nologin
I half remember this will make it disappear from the XDM login screen too, but I don't use XDM anymore, so that's a guess :-)
Solution 4
Using dscl
would give
dscl . -passwd /Users/myuser ""
Solution 5
Leaving the password field empty for the user in the passwd
file will work.
Related videos on Youtube
Mag Roader
I'm a senior Drupal developer, working as a consultant for Reveal IT. Over the past year I've spent a lot of time on Drupal and Drupal Commerce, created a lot of different sites with it and enjoyed it all the way. I maintain or co-maintain a host of modules on drupal.org and have contributed to a lot of other modules. Recently I've started contributing to Drupal core, making me in the top 5% of most contributions. When I'm not doing work or Drupal related stuff, I usually spend time with my beautiful wife and amazing son, play soccer, make grandiose cakes or some other fun stuff.
Updated on September 17, 2022Comments
-
Mag Roader over 1 year
In os X it's possible to have users without passwords. If you inspect them with
dscl
their password show up as*
. This is used for system users such as users for databases likemysql
,pgsql
etc. What's nice about this is that these users doesn't show up at the login screen and you can't login as them withoutsudo
etc.After deleting such a user trying some things out I wanted to recreate it, but couldn't. I could manage to get a user with a blank password and I could set the password to
*
. But none had the same effect as above, as the user showed up on my login screen.How do you create such a user?
-
Rimantas almost 14 yearsOn Linux, you pass the --disabled-password flag to adduser. Maybe OS X has something similar in its command line repertoire?
-
Chris Huang-Leaver almost 14 yearsDid you mean; user can log in without a password or can't log in at all because no password is set?
-
xenoterracide about 13 yearsI notice you didn't accept an answer... one requirement to stay out of the various xdm lists is having a significantly low userid. on many systems
useradd
starts adding id's at 1000, and the login managers won't show user id's below that, but everything above. so though it's not an answer to this question, it might be the resolution to the problem. please note that 1000 is arbitrary and may be lower or higher on your distribution. To fix just modify the user entry in/etc/passwd
to have a lower uid. Now for me to go ask similar question. -
Mag Roader about 13 years@xenoterracide: When I recreated the user, I gave it the old ID, it was the pgsql user I deleted which has an id of one higher than the mysql one, so I'm sure it didn't have any impact in this case, but thanks for the info anyways.
-
-
Shadur over 12 yearsI think that's the exact opposite of what is being asked for here.
-
HidekiAI about 9 yearsThis is the right answer because the OP asked for account which you cannot 'sudo' or show up on "login screen", by setting to '/sbin/nologin' for shell. One thing to note is because the OP asked for "system user", should also mention that 'useradd --system' should be used to create UID in low number (as portage/ebuild does)
-
HidekiAI about 9 yearsAt first, I thought this was the right (or best) answer, until I've re-read the OP's question, which mentions for "system user" and not show up on "login screen". This method will show up on login screen and you can 'sudo' using this method.
-
GroovyCakes over 6 yearsThis, unlike most of the answers above it... actually worked for me.