sshd_config 文件中的“无密码”是什么意思?

Joh*_*ohn 133 openssh sshd

我刚刚在我的服务器上安装了 Ubuntu 14.04,当我在我的sshd_config文件中遇到这个时,我正在设置我的所有配置文件:

# Authentication:
LoginGraceTime 120
PermitRootLogin without-password
StrictModes yes
Run Code Online (Sandbox Code Playgroud)

这让我非常担心。我认为有人可以在没有密码的情况下以 root 身份登录我的服务器。

我尝试通过以下方式以 root 用户身份连接到我的服务器:

johns-mbp:~ john$ ssh root@192.168.1.48
The authenticity of host '192.168.1.48 (192.168.1.48)' can't be established.
RSA key fingerprint is 40:7e:28:f1:a8:36:28:da:eb:6f:d2:d0:3f:4b:4b:fe.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.48' (RSA) to the list of known hosts.
root@192.168.1.48's password:  
Run Code Online (Sandbox Code Playgroud)

我输入了一个空白密码,但它没有让我进入,这让我松了一口气。所以我的问题是:没有密码意味着什么,为什么这是 Ubuntu 14.04 中的默认设置?

Flo*_*sch 161

联机帮助页

允许Root登录

指定 root 是否可以使用ssh (1)登录。参数必须是“yes”、“without-password”、“forced-commands-only”或“no”。默认值为“yes”。

如果此选项设置为“without-password”,则对 root 禁用密码验证。

如果此选项设置为“forced-commands-only”,则将允许使用公钥身份验证的 root 登录,但command前提是已指定该 选项(即使通常不允许 root 登录,这对于进行远程备份也很有用) . 对 root 禁用所有其他身份验证方法。

如果此选项设置为“否”,则不允许 root 登录。

因此without-password,仅允许使用公钥身份验证进行 root 登录。这通常与 shell 脚本和自动化任务一起使用。

  • 所以“没有密码”意味着除了密码之外的所有方法都允许吗?听起来真的像是“无需密码即可登录”。 (41认同)
  • `PermitRootLogin 现在接受“prohibit-password”的参数作为“without-password”的更明确的同义词。 (32认同)
  • 然而,正如您所看到的,虽然手册页指示默认值为“是”,但 Ubuntu 已将默认值设为“无密码”。 (5认同)
  • 不允许“root 登录”*使用密码* 被认为比允许它**更强的安全性**。*也就是说,您根本不应该登录 **root**,除非没有其他方法(sudo 等)有效。* (2认同)

Ata*_*911 18

实际上,如果您使用 PAM 身份验证,则此设置几乎没有任何作用。在sshd_config配置文件的底部,您会发现:

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
Run Code Online (Sandbox Code Playgroud)

Ubuntu 上的默认设置是使用 PAM 身份验证:

UsePAM yes
Run Code Online (Sandbox Code Playgroud)


tek*_*aul 6

在较新版本的 sshd(OpenSSH 7.0 及更高版本,于 2015 年 8 月 11 日发布)中,“ without-password”已更改为“ prohibit-password”。

两个版本都可以工作,prohibit-password如果可以的话,最好使用“ ”:它可以更好地解释自己。

来源

  • sshd_config(5):PermitRootLogin 现在接受“prohibit-password”的参数作为“without-password”的更明确的同义词。