Debian – 只允许一个用户通过ssh从任何IPlogin

我想configuration服务器,以便只有一个用户( git )能够从任何IP地址(使用密钥)login,而其他用户只能从指定的IPlogin。

当然,我的configuration允许从一个指定的IP地址login任何用户。

这是我现在拥有的:

/etc/ssh/sshd_config:

 PermitRootLogin no StrictModes yes RSAAuthentication yes PubkeyAuthentication yes # AllowUsers # not configured 

/etc/hosts.allow:

 # my workplace IP sshd: 191.225.37.xyz # my trusted server ALL: my.private.com 

/etc/hosts.deny:

 # bunch of addresses added by protection services sshd: xyzv 

UFW被禁用。

如何configuration它,以便任何用户只能从这个指定的IP(按原样)login,但git用户能够通过sshlogin任何IP?

你可能应该使用sshd_configmatch函数来完成这一切,而不是尝试使用tcp wrappers hosts.allow(这是官方sshd中的弃用函数)。 谷歌search可以find很多例子。 这是一个未经testing的例子,我期待的可能与你想要的相似。 请花点时间自行阅读手册页和其他Googlesearch结果。

 PasswordAuthentication no # git from anywhere with password auth Match User git PasswordAuthentication yes # anyone not git from a specific network with password auth Match User !git Address 192.168.0.0/16 PasswordAuthentication yes