此教程的作用:設置SSH只允許特定用戶從特定的IP登錄,其它未經允許的用戶和IP都不能登錄
示例1:只允許192.168.0.222登錄192.168.1.81
# vim /etc/hosts.allow,最后一行加入:
sshd:192.168.0.222:allow //多個IP可以按照此格式寫多行
# vim /etc/hosts.deny,最后一行加入:
sshd:ALL //除了上面允許登錄的IP,其它IP都拒絕登錄
# service sshd restart
示例2:只允許192.168.1網段的主機登錄192.168.1.81
# vim /etc/hosts.allow,最后一行加入:
sshd:192.168.1.*:allow
# vim /etc/hosts.deny,最后一行加入:
sshd:ALL
# service sshd restart
示例3:只允許192.168.0.222以keyso用戶身份、192.168.1.135以root用戶身份登錄192.168.1.81
# vim /etc/ssh/sshd_config,最后一行加入:
AllowUsers keyso@192.168.0.222 root@192.168.1.135 //多個用戶名@IP之間使用空格分隔
# service sshd restart