美文网首页
如何禁止ssh用户名密码登录

如何禁止ssh用户名密码登录

作者: CodingCode | 来源:发表于2022-11-07 02:56 被阅读0次
    1. 修改 /etc/ssh/sshd_config
    $ sudo vim /etc/ssh/sshd_config
    ...
    # To disable tunneled clear text passwords, change to no here!
    #PasswordAuthentication yes
    #PermitEmptyPasswords no
    PasswordAuthentication no
    
    # Change to no to disable s/key passwords
    #ChallengeResponseAuthentication yes
    ChallengeResponseAuthentication no
    ...
    

    PasswordAuthentication改成no,则ssh再发起登录的时候就会提示如下错误:

    ssh : Permission denied (publickey,gssapi-with-mic)
    

    通常禁止了用户名密码登录之后,需要配置public/private key pair进行登录,即ssh使用-i参数指定private key文件登录。

    反之如果ssh使用用户名密码登录遇到上述错误,则需要把 /etc/ssh/sshd_config配置文件里的配置项PasswordAuthentication改成yes

    相关文章

      网友评论

          本文标题:如何禁止ssh用户名密码登录

          本文链接:https://www.haomeiwen.com/subject/jlxwtdtx.html