SeeWlind
V2EX  ›  问与答

请教 ssh 禁用密码登录不生效的问题

  •  
  •   SeeWlind · Mar 31, 2023 · 3309 views
    This topic created in 1144 days ago, the information mentioned may be changed or developed.

    cat /etc/ssh/sshd_config

    PasswordAuthentication no

    已经按文档改了配置文件,重启了 ssd 服务,但是重启后还是可以用密码登录。

    请问还需要改什么配置吗?

    15 replies    2024-08-20 03:21:56 +08:00
    jomalonejia
        1
    jomalonejia  
       Mar 31, 2023
    怎么重启的
    SeeWlind
        2
    SeeWlind  
    OP
       Mar 31, 2023
    @jomalonejia Ubuntu 22.04 sudo systemctl restart sshd.service 这样的啊
    jomalonejia
        3
    jomalonejia  
       Mar 31, 2023
    @SeeWlind /etc/init.d/ssh restart 试试这个
    SeeWlind
        4
    SeeWlind  
    OP
       Mar 31, 2023
    @jomalonejia
    arch@ubuntu:~$ sudo /etc/init.d/ssh restart
    [sudo] password for arch:
    Restarting ssh (via systemctl): ssh.service.
    arch@ubuntu:~$ exit
    logout
    Connection to frp-arm.top closed.
    PS C:\Users\Admin> ssh -p xxx arch@xxxxxxxx
    arch@frp-arm.top's password:
    Welcome to Ubuntu 22.04.2 LTS (GNU/Linux 5.15.0-69-generic x86_64)

    还是没生效呵呵哈哈哈或或
    billlee
        5
    billlee  
       Mar 31, 2023 via Android
    Keyboard-interactive 关了吗?
    barathrum
        6
    barathrum  
       Mar 31, 2023 via iPad
    开 sshd 的 debug log 看看呢
    texsd123
        7
    texsd123  
       Mar 31, 2023 via Android
    xshell 有个挑战响应,这个应该也是密码登的,我关了就只能公私钥登录了

    ChallengeResponseAuthentication no
    gulucn
        8
    gulucn  
       Mar 31, 2023
    sshd_config 文件可能存在两个 PasswordAuthentication 配置?
    weiweiwitch
        9
    weiweiwitch  
       Mar 31, 2023
    有没有重启过机器试试?
    vnxi
        10
    vnxi  
       Mar 31, 2023 via Android
    把禁用密码那行放到配置文件的最上面
    blankmiss
        11
    blankmiss  
       Apr 1, 2023
    理论上应该改了就会生效 你重新搞一个新的 sshd.config 覆盖一次试试
    NidhoggRock
        12
    NidhoggRock  
       Sep 16, 2023
    sshd_config.d 目录下有一个 50-cloud-init.conf 文件,里面就只有一句话就是开启密码登录,我把它删除好像就可以了。
    NidhoggRock
        13
    NidhoggRock  
       Sep 16, 2023   ❤️ 3
    我的系统版本是 Ubuntu22.04
    sshd_config.d 目录下有一个 50-cloud-init.conf 文件,里面就只有一句话就是开启密码登录,我把它删除好像就可以了。
    @gulucn 最后弄下来好像确实是这样的,只是在 Include 的文件里,而且这个还 Include 还在最顶上。
    kisstrnt
        14
    kisstrnt  
       Jun 28, 2024
    @NidhoggRock 成功了
    mipaers
        15
    mipaers  
       Aug 20, 2024
    @NidhoggRock 终于找到了 感谢 我折腾了快一天
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3439 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 72ms · UTC 04:57 · PVG 12:57 · LAX 21:57 · JFK 00:57
    ♥ Do have faith in what you're doing.