I want to create an unprivileged user to run my RhodeCode server and Celery daemon on a CentOS instance. I think the accepted definition of this is no home directory, login disabled, and no shell access? Looking over the man page for adduser I just don't see an intuitive method for doing this. Any suggestions are appreciated. Thanks.
From here (centos.org)
useradd (which is the actual binary the runs when you call adduser, it just behaves differently. See here about that.) has an flag
-r which is documented as follows:
-r Create a system account with a UID less than 500 and without a home directory
Which sounds like what you want to do.
I think I should link here two answers from serverfault:
- how do i duplicate the nobody user? and
- Create restricted user on Debian server ( btw, it was moved to serverfault from stackoverflow, just recently -- and possibly could have been moved to this site as well )
-r means "set account as a system one" -- "no expiration", etc -- and the full spell may look like
useradd -s /bin/false -r <username>
useradd -s /usr/sbin/nologin -r -M -d /dev/null <username>
or similar )
NB. For things like samba one may also want to provide this user with a password and may be also add
# `which nologin` >> /etc/shells
NB(2): as per OrangeDog's comment:
-r actually implies
-M is not strictly necessary.
PS. And yes, looking for the same thing at serverfault, askubuntu -- and here -- seems a bit odd to me; is there a way to run a meta-search on, say, all stackoverflow sites ?
You're looking for the