7

LINUX随笔十七 /bin/false和/sbin/nologin的区别

 1 year ago
source link: https://blog.51cto.com/u_13236892/5445397
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

LINUX随笔十七 /bin/false和/sbin/nologin的区别

原创

哭泣的馒头 2022-07-05 22:31:19 博主文章分类:linux汇总 ©著作权

文章标签 无法登录 ftp服务器 linux 文章分类 Linux 系统/运维 阅读数167

/bin/false是最严格的禁止login选项,一切服务都不能用
/sbin/nologin只是不允许login系统
查看 /etc/passwd文件,能看到各用户使用的shell

二、具体介绍

1 nologin
当用户配置成/sbin/nologin时,如果再使用该用户ssh到linux操作系统,会礼貌的向用户显示一条信息,并拒绝用户登录:
This account is currently not available.
##这条信息显示的是/etc/nologin.txt里面的内容
有一些软件,比如一些ftp服务器软件,对于本地非虚拟账户,只有用户有有效的shell才能使用ftp服务。
这时候就可以使用nologin使用户即不能登录系统,还能使用一些系统服务,比如ftp服务。

2 false
当用户配置成/bin/false时,ssh之后显示如下
用户会无法登录,并且不会有任何提示
如果想要用false在禁止login的同时允许ftp,则必须在/etc/shells里增加一行/bin/false

三、附录/etc/nologin.txt和/etc/nologin

1、/etc/nologin.txt
当系统账号的shell为/sbin/nologin时,这是个特殊的shell,也就是说用这个shell的系统账号无法正常登陆。
当使用ssh登录这个账号时,这个时候会显示/etc/nologin.txt里面的说明内容,并无法登录

2、/etc/nologin
当/etc/nologin文件存在时,则任何一个非root的一般身份帐号在尝试登入时,都仅会获得/etc/nologin的内容,而无法直接登入主机。
即当建立/etc/nologin ,并且内容设定为『This Linux server is down』,则任何尝试登录者,会看到这些提示内容,而不能登录进系统。
直到删除/etc/nologin文件后,一般用户才可以正常登录。
  • 收藏
  • 评论
  • 分享
  • 举报

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK