在Debian服务器上创build受限用户

我想为我的debian服务器上安装的每个关键程序创build一个用户帐户。 例如,对于以下程序:

Tomcat Nginx Supervisor PostgreSQL

这似乎是build议根据我的在线阅读。 但是,我想尽可能限制这些用户帐户,以便他们没有shelllogin,不能访问其他程序,尽可能有限,但仍然function。

有谁会介意告诉我这是如何实现的? 到目前为止,我的阅读暗示着:

echo "/usr/sbin/nologin" >> /etc/shells useradd -s /usr/sbin/nologin tomcat 

但我认为可能有一个更完整的方式来做到这一点。

编辑:我使用debian挤压

这是正确的轨道,但是您需要指出它是系统用户,以便/etc/shadow不会有任何老化信息。 从useradd手册页:

-r, --system

  Create a system account. System users will be created with no aging information in /etc/shadow, and their numeric identifiers are choosen in the SYS_UID_MIN-SYS_UID_MAX range, defined in /etc/login.defs, instead of UID_MIN-UID_MAX (and their GID counterparts for the creation of groups). Note that useradd will not create a home directory for such an user, regardless of the default setting in /etc/login.defs (CREATE_HOME). You have to specify the -m options if you want a home directory for a system account to be created. 

所以你会想要的东西沿线:

 useradd -s /usr/sbin/nologin -r -M tomcat 

你也可以创build一个主目录,如果你想,也许是属于该服务的东西,例如:

 useradd -s /usr/sbin/nologin -r -M -d /etc/nginx nginx