歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Unix知識 >> 關於Unix >> ssh的用戶登陸限制

ssh的用戶登陸限制

日期:2017/3/6 15:39:27   编辑:關於Unix
預設上,sshd 不受 xinetd 管,但可支援 tcpd 。 你可在 hosts.allow 中設: sshd: 192.168.0. sshd: ALL: deny 當然,用 iptables 也行: iptables -I INPUT -p tcp --dport 22 -j DROP iptables -I INPUT -p tcp --dport 22 -s 192.168.0.0/32 -j A CC EPT

預設上,sshd 不受 xinetd 管,但可支援 tcpd 。
你可在 hosts.allow 中設:
sshd: 192.168.0.
sshd: ALL: deny

當然,用 iptables 也行:
iptables -I INPUT -p tcp --dport 22 -j DROP
iptables -I INPUT -p tcp --dport 22 -s 192.168.0.0/32 -j ACCEPT
(註:用 -I 命令,且順序不能顛倒...)

再補:

若你還想限制哪些用戶可用,請 man sshd_config 找找 AllowGroups 與 AllowUsers 設定。
或用 pam 也行:
1) 修改 /etc/pam.d/sshd
auth required pam_listfile.so item=user sense=allow file=/etc/sshusers onerr=fail
2) 將你要的用戶寫進 /etc/sshusers ,如:
echo "root" >> /etc/sshusers

Copyright © Linux教程網 All Rights Reserved