linux遠程訪問權限控制(hosts.allow和hosts.deny)

etc/hosts.allow和/etc/hosts.deny兩個文件是控制遠程訪問設置的,通過他可以允許或者拒絕某個ip或者ip段的客戶訪問linux的某項服務。
比如SSH服務,我們通常只對管理員開放,那我們就可以禁用不必要的IP,而只開放管理員可能使用到的IP段。
使用:
修改/etc/hosts.allow文件
#
# hosts.allow   This file describes the names of the hosts which are
#               allowed to use the local INET services, as decided
#               by the '/usr/sbin/tcpd' server.
#
sshd:210.13.218.*:allow
sshd:222.77.15.*:allow
以上寫法表示允許210和222兩個ip段連接sshd服務(這必然需要hosts.deny這個文件配合使用),當然:allow完全可以省略的。
當然如果管理員集中在一個IP那麼這樣寫是比較省事的
all:218.24.129.110//他表示接受110這個ip的所有請求!
/etc/hosts.deny文件,此文件是拒絕服務列表,文件內容如下:
#
# hosts.deny    This file describes the names of the hosts which are
#               *not* allowed to use the local INET services, as decided
#               by the '/usr/sbin/tcpd' server.
#
# The portmap line is redundant, but it is left to remind you that
# the new secure portmap uses hosts.deny and hosts.allow.  In particular
# you should know that NFS uses portmap!
sshd:all:deny
注意看:sshd:all:deny表示拒絕了所有sshd遠程連接。:deny可以省略。
所以:當hosts.allow和 host.deny相沖突時,以hosts.allow設置爲準。
注意修改完後:
service xinetd restart
才能讓剛纔的更改生效。
總結:通過這種方法可以控制部分非授權訪問,但不是一勞永逸的方法!我們在看服務日誌的時候或許會看到很多掃描記錄,不是還是直接針對root用戶的,這時控制你的訪問列表就非常有作用了!
本文來自: (
www.91linux.com
) 詳細出處參考:
http://www.91linux.com/html/article/guanli/20070625/2952.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章