PbCopy111
V2EX  ›  问与答

ssh 能不能内网用密码,外网用证书的登录?

  •  
  •   PbCopy111 · Aug 3, 2021 · 1295 views
    This topic created in 1808 days ago, the information mentioned may be changed or developed.

    因为我的 ssh 面对公网开放了,所以修改了端口,并且使用证书登录。 可是内网的机器登录的时候,不是每台电脑都有证书,有的时候还是需要密码的,可我查了一下,没法设置不同端口验证方式不同,所以还有什么办法么??

    3 replies    2021-08-03 17:42:38 +08:00
    24owls
        1
    24owls  
       Aug 3, 2021
    开两个 sshd 啊,分别用两个不同的 sshd.conf 配置
    ed448
        2
    ed448  
       Aug 3, 2021 via iPhone
    密码验证和公钥验证不是唯一项可以同时设定
    jim9606
        3
    jim9606  
       Aug 3, 2021   ❤️ 1
    用 sshd_config Match 条件块( https://man.openbsd.org/sshd_config#Match )

    例如这样子

    ```
    Match Host !10.0.0.0/8, User admin
    PasswordAuthentication no
    PubkeyAuthentication yes
    Match Host 10.0.0.0/8, User admin
    PasswordAuthentication yes
    PubkeyAuthentication yes
    ```

    应用配置前先用虚拟机测试一下配置是否按预期运作。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3854 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 49ms · UTC 10:31 · PVG 18:31 · LAX 03:31 · JFK 06:31
    ♥ Do have faith in what you're doing.