1.編輯/etc/hosts.allow文件
# vim /etc/hosts.allow
添加指定IP貨值IP段
# 允許192.168.1.10 IPssh連接
sshd : 192.168.1.10 : allow
# 允許192.168.2. IP段ssh連接
sshd : 192.168.2.* : allow
all:192.168.1.12//他表示接受12這個ip的所有請求!(不推薦)
2.編輯/etc/hosts.deny文件
# vim /etc/hosts.deny
最後添加 sshd:all:deny
# sshd:all:deny(拒絕所有請求,當hosts.allow和 host.deny相沖突時,以hosts.allow設置爲準)
3.重啓sshd服務
# /bin/systemctl restart sshd.service