将特定用户的 SSH 登录限制到特定 IP 地址

Kei*_*Jr. 5 ssh

我想将特定 FreeBSD 用户帐户的 SSH 登录限制为特定 IP 地址(它们是从一台机器到另一台机器的自动 rsync 备份,没有实际用户应该登录,只是 SSH+rsync 过程)。

我觉得我应该能够使用 hosts.allow 或 sshd_config 来做到这一点……但我找不到任何明确的例子来说明如何做到这一点。谁能告诉我?

War*_*ner 0

来自hosts.allow 联机帮助页:

CLIENT USERNAME LOOKUP
       When the client host supports the RFC  931  protocol  or  one  of  its
       descendants  (TAP,  IDENT, RFC 1413) the wrapper programs can retrieve
       additional information about the owner of a connection.  Client  user-
       name  information,  when available, is logged together with the client
       host name, and can be used to match patterns like:

          daemon_list : ... user_pattern@host_pattern ...
Run Code Online (Sandbox Code Playgroud)