`
sinxadmin
  • 浏览: 79970 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

linux远程访问权限控制(hosts.allow和hosts.deny)

    博客分类:
  • Unix
阅读更多
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

才能让刚才的更改生效。





Linux下防止未授权IP使用ssh服务

方法一

iptables -A INPUT -p tcp -s 192.168.0.0/24 --destination-port 22 -j ACCEPT

iptables -A INPUT -p tcp -s 192.168.1.0/24 --destination-port 22 -j ACCEPT

iptables -A INPUT -p tcp -s ! 127.0.0.1 --destination-port 22 -j DROP

方法二

[root@nihao ~]# more /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

[root@nihao ~]# more /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: 192.168.0.230 :allow

这里写允许的ip或者网段
分享到:
评论
1 楼 isaiahzhong 2012-11-21  
       不对啊,我在hosts.allow下面什么都不配置,hosts.deny下面配置了sshd:all:deny ,按照道理来说都不能远程访问,可是还是可以访问,有兴趣一起讨论

相关推荐

    操作系统安全:配置etchosts.allow及etchosts.deny.docx

    /etc/hosts.allow和/etc/hosts.deny两个文件是控制远程访问设置的,通过他可以允许或者拒绝某个ip或者ip段的客户访问linux的某项服务。 比如SSH服务,我们通常只对管理员开放,那我们就可以禁用不必要的IP,而只开放...

    操作系统安全:详解etc hosts.deny .docx

    /etc/hosts.allow和/etc/hosts.deny两个文件是控制远程访问设置的,通过他可以允许或者拒绝某个ip或者ip段的客户访问linux的某项服务。 比如SSH服务,我们通常只对管理员开放,那我们就可以禁用不必要的IP,而只开放...

    openssh 8.4版本的RPM包,支持hosts.allow的版本 openssh-server-8.4p1-1.el7.centos.x86_64.rpm

    openssh-server-8.4p1-1.el7.centos.x86_64.rpm源生的openssh的版本不支持tcpwraper

    hosts.deny

    不知道为什么不能 0资源分。这是防止到hosts.deny的内容,防止SSH暴力登陆。

    TCPwrapper访问控制工具

    TCPwrapper访问控制工具 ...TCPwrappers会先查找/etc/hosts.allow,再查找/etc/hosts.deny,如果两个配置中有冲突,先匹配中的优先,也就是/etc/hosts.allow中的配置优先,如果两个配置都没命中,默认放

    linux详细目录架构

    /etc/hosts.allow 设置允许使用inetd的机器使用 /etc/hosts.deny 设置不允许使用inetd的机器使用 /etc/hosts.equiv 设置远端机不用密码 /etc/inetd.conf 设定系统网络守护进程inetd的配置 /etc/gateways ...

    linux常用命令

    /etc/hosts.allow 设置允许使用inetd的机器使用 /etc/hosts.deny 设置不允许使用inetd的机器使用 /etc/hosts.equiv 设置远端机不用密码 /etc/inetd.conf 设定系统网络守护进程inetd的配置 /etc/gateways 设定...

    openssh-8.4p1-1.el7.centos.x86_64.rpm

    openssh-8.4p1-1.el7.centos.x86_64.rpm以来的openssh包,源生的版本不支持hosts.allow,hosts.deny.

    Linux网络服务器配置基础(下)

    * /etc/hosts.allow 文件但是对于telnet、ftp等服务,如果将其一同关闭,那么对于管理员需要远程管理时,将非常不方便.Linux提供另外一种更为灵活和有效的方法来实现对服务请求用户的限制,从而可以在保证安全性的基础上...

    操作系统安全审计.doc

    1. RedHat Linux操作系统 RedHat Linux操作... " "查看hosts.allow和hosts.deny文件内容。 " "测试记录: " "已配置的日志: " " " " " " " "日志功能是否有效实施,日志记录的日期和内容是否与配置相符合: " " " "

    sshban:控制您的 SSH 登录

    然后使用您的 /etc/hosts.deny 和 /etc/hosts.allow 来控制您的 SSHD。 在 /etc/hosts.deny 添加以下行 sshd: ALL 在 /etc/hosts.allow 添加以下行 sshd: ALL: aclexec /usr/local/bin/sshban.sh

    sshd 限制登陆的几种方法总结

    1. 在 /etc/hosts.allow 写: 在/etc/hosts.allow写: sshd: 1.2.3.4 在 /etc/hosts.deny 写: sshd: ALL  2. 用 iptables 也行: iptables -I INPUT -p tcp --dport 22 -j DROP iptables -I INPUT -p tcp --...

    超级服务器和telnet

    linux基本网络服务管理: 1、什么是守护进程(daemon) 2、超级服务器xinetd 3、xinetd举例:使用xinetd管理telnet 4、tcpd及其配置文件/etc/hosts.allow和/etc/hosts.deny

    信息系统安全基线.docx

    配置/etc/hosts.allow, /etc/hosts.deny 安装TCP Wrapper,提高对系统访问控制 用户账号与口令 通过配置操作系统用户账号与口令安全策略,提高系统账号与口令安全性,详见表2。 表2 AIX系统用户账户与口令基线技术...

    map-deny:通过 GeoIP 查找生成 hosts.deny 位置地图

    使用 geoip 查找和 OpenLayers 3 映射被拒绝主机 IP 的位置。 该产品包括由 MaxMind 创建的 GeoLite2 数据,可从。 ##Setup 重命名和编辑配置文件 mv config_SAMPLE.py config.py ... python map-deny.py

    Apache配置文件中的deny与allow小结

    主要介绍了Apache配置文件中的deny与allow小结,本文着重讲解了deny和allow的执行顺序问题,需要的朋友可以参考下

    Apache配置参数deny和allow的使用实例.docx

    Apache配置参数deny和allow的使用实例.docx

    Centos中TCPWrappers访问控制实现

    一、TCP Wrappers概述 TCP Wrappers将TCP服务程序“包裹”起来,代为监听TCP服务程序的端口,增加了一个...对应的两个策略文件为/etc/hosts.allow和/etc/hosts.deny,分别用来设置允许和拒绝的策略。 1、策略的配置

    限制ip访问Oracle数据库的方法步骤

    通过/etc/hosts.deny和/etc/hosts.allow 通过iptables 二、正式实验 本次实验环境是Centos6.10 + Oracle 11.2.0.4单实例,数据库服务器ip地址为192.168.31.71 1. 通过sqlnet.ora a. 关闭数据库服务器上的防火墙,...

Global site tag (gtag.js) - Google Analytics