SeeWlind
V2EX  ›  问与答

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

  •  
  •   SeeWlind · Mar 31, 2023 · 3935 views
    This topic created in 1318 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
    jomalonejia
    Mar 31, 2023
    1
    怎么重启的
    SeeWlind
    SeeWlind
    OP
    Mar 31, 2023
    2
    @jomalonejia Ubuntu 22.04 sudo systemctl restart sshd.service 这样的啊
    jomalonejia
    jomalonejia
    Mar 31, 2023
    3
    @SeeWlind /etc/init.d/ssh restart 试试这个
    SeeWlind
    SeeWlind
    OP
    Mar 31, 2023
    4
    @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
    billlee
    Mar 31, 2023 via Android
    5
    Keyboard-interactive 关了吗?
    barathrum
    barathrum
    Mar 31, 2023 via iPad
    6
    开 sshd 的 debug log 看看呢
    texsd123
    texsd123
    Mar 31, 2023 via Android
    7
    xshell 有个挑战响应,这个应该也是密码登的,我关了就只能公私钥登录了

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