permitrootlogin(permitrootlogin no 后为什么root还是可以远程登录)

本文目录
permitrootlogin no 后为什么root还是可以远程登录
PermitRootLogin如果不设置,默认是yes,也就是root可以登录
如果设置without-password 那么root可以登录,但是不允许通过密码ssh登陆
如果设置no, root不许登陆
如果设置forced-commands-only,则可以登录,但是登陆后不能进入交互,而是执行指定的命令后 自动退出,指定的命令在authorized_keys里面列出例如/bin/date
man的描述如下
PermitRootLogin
Specifies whether root can log in using ssh(1). The argument must be “yes”,
“without-password”, “forced-commands-only”, or “no”. The default is “yes”.
If this option is set to “without-password”, password authentication is disabled for root.
If this option is set to “forced-commands-only”, root login with public key authentication
will be allowed, but only if the command option has been specified (which may be useful for
taking remote backups even if root login is normally not allowed). All other authentica‐
tion methods are disabled for root.
If this option is set to “no”, root is not allowed to log in.
如何修改permitrootlogin 只读文件
ssh的修改 vi /etc/ssh/sshd_config 将默认的 #PermitRootLogin yes 去注释改为 PermitRootLogin no
ssh的修改 vi /etc/ssh/sshd_config 将默认的 #PermitRootLogin yes 去注释改为 PermitRootLogin no

更多文章:
电脑wifi驱动没了怎么办(华硕笔记本更新后wifi驱动掉了怎么办)
2026年9月25日 10:20
天涯明月刀删号事件(《天涯明月刀》删号事件火了,具体是什么情况)
2026年8月27日 15:10
太极拳24式慢动作视频(二十四式太极拳的各个动作的名称按顺序是怎样的)
2026年2月18日 14:15

















