在Debian 10中我想创建一个无法直接登录的用户。人们应该只能通过使用su二进制文件来访问用户。在我的 Ubuntu 18.04 设置中,我确实做到了这一点,并且它的工作非常顺利,但在 Debian 10 中我无法这样做。
能够登录的用户将没有使用权限sudo。
我已经使用默认 shell 设置了一个用户/usr/sbin/nologin。但是当我尝试访问该用户时,su --shell=/bin/bash user我无法这样做。
# useradd --shell /usr/sbin/nologin locked
# passwd locked
Enter new UNIX password: *secret*
Retype new UNIX password: *secret*
passwd: password updated successfully
$ su --shell /bin/bash locked
Password: *secret*
This account is currently not available.
Run Code Online (Sandbox Code Playgroud)
为什么这在 Debian 中不再起作用?
输出/etc/shells:
$ cat /etc/shells
# /etc/shells: valid login shells
/bin/sh
/bin/dash
/bin/bash
/bin/rbash …Run Code Online (Sandbox Code Playgroud)