只允许从一个IP访问shell

是否有可能从一个特定的IP只能访问root shell

我正在使用centOS。 我希望只有一个用户可以通过shell从一个iplogin

是的,将以下内容添加到sshd_config以启用仅密钥login并限制到特定的IP地址。

AllowUsers [email protected] PermitRootLogin without-password 

你可以使用iptables防火墙规则

 iptables -I INPUT -s <IP> -p tcp -m tcp --dport 22 -j ACCEPT iptables -I INPUT -p tcp -m tcp --dport 22 -j REJECT 

另一种方法是通过/etc/hosts.allow和/etc/hosts.deny使用tcp wrapper – 参见我的页面: http : //wiki.xdroop.com/space/Linux/Limited+SSH+访问

你可以使用提示行

 PermitRootLogin without-password 

在sshdconfiguration。 如果你使用root用户的authorized_keys文件中的公钥的前缀

 from="vxyz" ... 

那么它应该有预期的效果。

请参阅sshd手册页,在AUTHORIZED_KEYS FILE FORMAT部分中进行了解释。