是否要求 OpenSSH 中特定用户进行公钥认证?

是否要求 OpenSSH 中特定用户进行公钥认证?

如何配置我的 OpenSSH 服务器以要求特定(常规、非 root)用户进行公钥认证?所有其他用户都可以照常通过密码登录。

答案1

您可以在中使用以下内容/etc/ssh/sshd_config

Match User attie
    AuthenticationMethods publickey

请注意,Match各部分需要位于配置文件的末尾...

不要忘记重新加载 SSH 服务器:

systemctl reload ssh

 AuthenticationMethods
        Specifies the authentication methods that must be successfully completed for a
        user to be granted access.  This option must be followed by one or more comma-
        separated lists of authentication method names.  Successful authentication
        requires completion of every method in at least one of these lists.

        For example, an argument of "publickey,password publickey,keyboard-interactive"
        would require the user to complete public key authentication, followed by
        either password or keyboard interactive authentication.  Only methods that are
        next in one or more lists are offered at each stage, so for this example, it
        would not be possible to attempt password or keyboard-interactive
        authentication before public key.

相关内容