6

I need help adding a system user to my CentOS server. I have two commands that works on Ubuntu Server, however I have to find a replacement for CentOS while keeping the same result. The commands are:

sudo adduser --system --shell /bin/sh --gecos 'Git Version Control' --group --disabled-password --home /home/git git
sudo adduser --disabled-login --gecos 'GitLab' gitlab

The options that I can't find on CentOS are --system, --disabled-password and --disabled-login.

Stefano
  • 197
  • 1
  • 1
  • 6

1 Answers1

6

You want to take a look at man useradd. You seem to have a good grasp of what you want to do but adduser = useradd in RHEL/CentOS.

  • -r = --system
  • For the other options, I think you just want to lock the account with passwd -l <username> after the account is created.

Make sure empty passwords are not allowed by PAM;

Look in /etc/pam.d/system-auth and /etc/pam.d/password-auth and remove nullok from the pam_unix.so lines (if applicable.)

Ubuntu's adduser
& useradd

Aaron Copley
  • 12,525
  • 5
  • 47
  • 68
  • -r doesn't create the homedir. What if I need a system user which can login not via password but via ssh and with his own user home directory? – Stefano Jan 18 '13 at 19:43
  • Right, `-m` creates the home directory, `-r` just makes the UID < 500 which is convention for a system account. Look at all the options available for `useradd`, there aren't too many. – Aaron Copley Jan 18 '13 at 19:44
  • can I use -r and -m together? – Stefano Jan 18 '13 at 19:44
  • Sure, can! They are not mutually exclusive. – Aaron Copley Jan 18 '13 at 19:45
  • one last question: in the commands of Ubuntu I have the --group option which (from the docs) when combined with --system, creates a group with the same name and ID as the system user. If not combined with --system, a group with the given name is created. As on Ubuntu the --system option is specified, what should I do on CentOS to get the same result? – Stefano Jan 18 '13 at 19:50
  • That's default behavior -- I just tested to confirm. – Aaron Copley Jan 18 '13 at 20:00