SSH:仅接受来自本地主机的密码连接

Thi*_*uce 5 ssh config sshd

我希望能够使用密码连接到 root@localhost,并仅使用私钥从外部 (root@my-ip) 连接。我没有找到在 /etc/ssh/sshd_config 中写什么来允许 this\xe2\x80\xa6 如果它需要 SSH 密钥和密码,也可以。

\n\n

你有好主意吗?

\n

Jak*_*uje 6

这取决于你的 openssh 版本,但在最近的版本中,你可以设置:

PermitRootLogin prohibit-password
Match LocalAddress 127.0.0.1,::1  # localhost
  PermitRootLogin yes
Run Code Online (Sandbox Code Playgroud)

或者使用您的版本 ( ) 支持的其他等效项PasswordAuthentication