TCP Wrapper 特殊使用

  更多,更好内容请参见: http://www.ibm.com/developerworks/cn/aix/library/au-tcpwrapper/

一. 用处和用法

  没有符合hosts.allow,hosts.deny中的配置的主机,用ssh登陆到我的系统的时候,我希望记录下他的动作,以便用于查询认证只用,这个时候就可以用到TCP Wrappers 的特殊功能。 但是要确定安装tcp_wrappers软件才能使用: " yum install tcp_wrappers"。 这时,就会有更加详细的操作:

  spawn : 可以利用后续的shell进行额外的工作,并且可以使用变量:

    %h:  hostname

    %a:  address

    %d:  daemon

  twist:  立刻一后续的命令进行,且执行完后终止此次连接

二. 简单范例

  1. spawn的使用:

    1.1 设置hosts.allow,hosts.deny. 加入相应的spawn配置。

    达到的目标: 如果是未经允许的网段登录到我的主机时,就向root账户发送一条mail,mail的内容形式为:

      security notice from host ****

      the host **** which is not permitted tried to ssh to you computer

    hosts.allow

#
# hosts.allow    This file contains access rules which are used to
#        allow or deny connections to network services that
#        either use the tcp_wrappers library or that have been
#        started through a tcp_wrappers-enabled xinetd.
#
#        See ‘man 5 hosts_options‘ and ‘man 5 hosts_access‘
#        for information on rule syntax.
#        See ‘man tcpd‘ for information on tcp_wrappers
#
sshd:    192.168.1.2,192.168.1.1: allow

    hosts.deny

    

#
# hosts.deny    This file contains access rules which are used to
#        deny connections to network services that either use
#        the tcp_wrappers library or that have been
#        started through a tcp_wrappers-enabled xinetd.
#
#        The rules in this file can also be set up in
#        /etc/hosts.allow with a ‘deny‘ option instead.
#
#        See ‘man 5 hosts_options‘ and ‘man 5 hosts_access‘
#        for information on rule syntax.
#        See ‘man tcpd‘ for information on tcp_wrappers
#
sshd:    ALL    :spawn ( echo "security notice from host $(/bin/hostname)"; \          echo "the host %h which is not permitted tried to ssh to you computer"; echo;) |              /bin/mail -s "%d-%h security" root 

    1.2 用不在允许范围的主机192.168.1.12尝试用ssh登陆到这台主机(192.168.1.11)

    主机拒绝登陆

    

    1.3 在主机(192.168.1.11)查看收到的新mai,内容如下:

    l

  2.twist用法

    在hosts.deny文件后边加上设置:

    

#
# hosts.deny    This file contains access rules which are used to
#        deny connections to network services that either use
#        the tcp_wrappers library or that have been
#        started through a tcp_wrappers-enabled xinetd.
#
#        The rules in this file can also be set up in
#        /etc/hosts.allow with a ‘deny‘ option instead.
#
#        See ‘man 5 hosts_options‘ and ‘man 5 hosts_access‘
#        for information on rule syntax.
#        See ‘man tcpd‘ for information on tcp_wrappers
#
sshd:    ALL    :spawn ( echo "security notice from host $(/bin/hostname)"; \          echo "the host %h which is not permitted tried to ssh to you computer"; echo;) |              /bin/mail -s "%d-%h security" root &              :twist (/bin/echo "YOU ARE NOT ALLOWED TO ENTER THE COMPUTER")

    在192.168.1.12上用ssh登陆到192.168.1.11上时,并没有出现YOU ARE NOT ALLOWED TO ENTER THE COMPUTER。 查找了很长时间的问题,但是依然没有解决。

    这样 sshd: ALL :twist (/bin/echo "YOU ARE NOT ALLOWED TO ENTER THE COMPUTER"),也不行。

    求高手解答

    

时间: 2024-08-30 01:40:09

TCP Wrapper 特殊使用的相关文章

Linux运维 第三阶段 (十二)tcp wrapper

Linux运维第三阶段(十二)tcp wrapper tcp wrapper tcp wrapper(工作在TCP层的访问控制工具,通常只对TCP协议的应用做控制,它本身只是个库文件libwrap.so(由glibc提供)) 当来自客户端的请求访问本机服务时,请求先到达本机网卡,再到内核TCP/IP协议栈,路由发现是访问本机的,转至用户空间服务所监听的套接字上,服务响应送至内核TCP/IP协议栈,再通过路由经网卡返回至客户端:有了tcp wrapper后,在这过程当中附加了一层访问控制机制,由t

Linux中TCP wrapper的使用

Linux中TCP wrapper的使用 tcpwrapper的目的是对那些访问控制功能较弱的服务提供访问控制功能要想了解访问控制就必须先知道服务监听的概念: 服务监听的两种方式: listen     :        socket                  监听在套接字上提供服务                    循环                   不停歇的查看某个端口来提供服务 有两种方式来判断一个服务是否支持tcp wrapper: 1.通过查找库文件看是否有libwr

linux下tcp wrapper 使用详解

wrapper是一款访问控制的工具,很类似iptables的功能,但是要比iptables功能要小很多,一般只有在满足以下条件时才能使用tcp wrapper 检查要控制的软件工具是否支持tcp_wrap: ldd /usr/sbin/sshd(如果有wrap库代表支持)/ ldd `which xinted` | grep libwrap wrapper访问控制语句是写在:/etc/hosts.allows和/etc/hosts.deny 这两个文件当中 下面我举一些例子1: /etc/hos

Linux自学笔记——tcp wrapper

tcp_wrapper:tcp包装器,是一个由wieste venema开发,旨在为unix/linux服务器提供防火墙服务的免费软件,它能够让系统管理员记录和控制wrappers支持基于tcp的服务或守护进程的访问. tcp_wrappers是用来辅助而非替代netfilter的,因为tcp_wrappers工作在应用层,而netfilter工作在网络层: 库文件:libwrap.so /etc/hosts.allow  , /etc/hosts.deny 判断某服务是否能够由tcp_wrap

Tcp Wrapper <备忘>

查看ssh服务是否支持tcpwrapper: ldd `which -a sshd` | grep wrap 配置文件:/etc/hosts.allow ; /etc/hosts.deny 1.记录日志: 修改/etc/hosts.deny: sshd: 172.16.20.211: severity warning    #定义日志的级别为warning 修改/etc/rsyslog.conf: authpriv.warning        /var/log/warning 重启服务: /e

linux TCP Wrappers

1. TCP Wrapper简介 (维基百科)TCP Wrapper is a host-based Networking ACL system, used to filter network access to Internet Protocolservers on (Unix-like) operating systems such as Linux or BSD. It allows host or subnetwork IP addresses,names and/or ident qu

ftp服务搭建配置管理

ftp[file transfer protocol这是档案传输的通讯协议,也是一般最常用来传送档案的方式这是档案传输的通讯协议,也是一般最常用来传送档案的方式]是/tcp/ip的一种具体的应用,工作在OSI上的第七层,TCP/IP模型的第四层,是一种面向连接的协议,工作模式分为主动模式和被动模式 vsftpd是UNIX类操作系统上运行的服务器名称,它的名字代表"very secure FTP daemon",安全性是其设计与开发的一个重要目标,支持很多其他的FTP 服务器不支持的特征

Iptables/Netfilter应用总结

目录: 一.理论部分. 二.实验部分. **********************************理论部分********************************** 1. 前提知识 任何主机若要与非同网络中的主机通信,则必须将报文发送到默认网关:对Linux而言,IP地址是属于主机(内核中)的,不属于网卡,只要属于当前主机的IP地址间,都可直接响应,不能称为转发:私有地址在路由器上是不允许被路由的 2. iptables简介: netfilter/iptables(简称为ip

SSH防暴力破解软件 Denyhosts

原理: DenyHosts 是Python语言写的一个开源程序,它会定期分析sshd服务的登陆日志,当发现某IP进行多次SSH登陆且登陆失败次数超过阈值时,会将IP记录到 /etc/hosts.deny文件,通过tcpwrapper达到自动屏蔽IP的功能. TCP wrapper: tcpwrapper 是一个为 Unix 类服务器提供防火墙服务的程序,任何以 Xinetd 管理的服务都可以通过TcpWrapper来设置防火墙,简单的说,就是针对源IP或域进行允许或拒绝访问的设置: 配置文件: