SSH:仅接受来自本地主机的密码连接
SSH: accept connection with password only from localhost
我希望能够使用密码连接到 root@localhost,并且仅使用私钥从外部 (root@my-ip) 连接。我没有找到在 /etc/ssh/sshd_config 中写什么来允许这个…如果它需要一个 SSH 密钥和一个密码也没关系。
你有什么想法吗?
这取决于你的openssh版本,但在最近的版本中,你可以设置:
PermitRootLogin prohibit-password
Match LocalAddress 127.0.0.1,::1 # localhost
PermitRootLogin yes
或使用您的版本 (PasswordAuthentication
) 支持的其他等效项。
我希望能够使用密码连接到 root@localhost,并且仅使用私钥从外部 (root@my-ip) 连接。我没有找到在 /etc/ssh/sshd_config 中写什么来允许这个…如果它需要一个 SSH 密钥和一个密码也没关系。
你有什么想法吗?
这取决于你的openssh版本,但在最近的版本中,你可以设置:
PermitRootLogin prohibit-password
Match LocalAddress 127.0.0.1,::1 # localhost
PermitRootLogin yes
或使用您的版本 (PasswordAuthentication
) 支持的其他等效项。