只允許從一個 ip 存取 shell

只允許從一個 ip 存取 shell

是否可以僅從一個特定的 ip 進行 root shell 訪問

我使用的是centOS。我希望只有一個使用者可以從一個 ip 透過 shell 登入

答案1

是的,將以下內容新增至 sshd_config 以啟用僅金鑰登入並限制為特定 IP 位址。

AllowUsers [email protected]
PermitRootLogin without-password

答案2

您可以使用 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

答案3

另一種方法是透過 /etc/hosts.allow 和 /etc/hosts.deny 使用 tcp 包裝器 - 請參閱我的頁面:http://wiki.xdroop.com/space/Linux/Limited+SSH+Access

答案4

相關內容