将SSH设置为只使用密钥而不使用密码

  • 本文关键字:密码 密钥 SSH 设置 ssh
  • 更新时间 :
  • 英文 :


我们有一个服务器,您可以ssh到它。但是,我们设置了公共加密密钥。我们希望登录的唯一方法是通过身份验证的密钥。无法使用密码登录。有办法做到这一点吗?

编辑:

passwd -l account

似乎使得没有SSH密钥就无法登录帐户

设置sshd_config中所有其他认证类型为no

RSAAuthentication no
PasswordAuthentication no
UsePAM no
KerberosAuthentication no
GSSAPIAuthentication no

您可以尝试将PasswordAuthentication no行添加到/etc/ssh/sshd_config。可能取决于操作系统

最新更新