Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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 like mysql, 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 without sudo 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?

share|improve this question
    
On Linux, you pass the --disabled-password flag to adduser. Maybe OS X has something similar in its command line repertoire? –  B.R. Aug 10 '10 at 21:00
    
Did you mean; user can log in without a password or can't log in at all because no password is set? –  Chris Huang-Leaver Aug 10 '10 at 21:08
1  
I 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. –  xenoterracide Apr 7 '11 at 19:53
    
@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. –  googletorp Apr 7 '11 at 21:16

6 Answers 6

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 :-)

share|improve this answer

You can run passwd --delete <username> after creating the user with adduser. After this, you'll be able to login without entering a password.

share|improve this answer
1  
I think that's the exact opposite of what is being asked for here. –  Shadur Nov 29 '11 at 13:37

I can't be certain about OSX, but on FreeBSD you can use:

pw add user mymuser -g mygroup -s /nonexistent -h -

the value of - passed to the -h option tells pw to set the password field in master.passwd to *, thus creating a no-login account. Setting the shell isn't strictly necessary, but avoids a shell check from /etc/pw.conf.

share|improve this answer

Leaving the password field empty for the user in the passwd file will work.

share|improve this answer

If you are on Ubuntu you can swap in the password for the Ubuntu user in /etc/shadow check out this article:

http://www.psychocats.net/ubuntucat/creating-a-passwordless-account-in-ubuntu/

share|improve this answer

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.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.