仅 SSH 密钥远程登录,禁用密码是一个好习惯吗?

仅 SSH 密钥远程登录,禁用密码是一个好习惯吗?

我需要一个只需要远程登录的维护用户。我最好只使用公钥来登录帐户。

我想到只使用 创建用户useradd myuser,然后将所需的公钥添加到其authorized_hosts文件中。

useradd默认情况下禁用密码。我还需要运行 apasswd -l myuser来锁定它吗?

这里有什么缺点吗?

答案1

是的,这里有一些缺点。您正在使用无密码身份验证来提高安全性。因为提供密码将是登录系统的第二扇门。所以在

/etc/ssh/sshd_config


PasswordAuthentication no
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile      .ssh/authorized_keys
ChallengeResponseAuthentication no
GSSAPIAuthentication no

此更改将仅使用公钥进行身份验证,在任何情况下都不会询问密码。这将是保护远程登录的良好安全程序。

相关内容