更多,更好内容请参见: 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"),也不行。

    求高手解答

    

TCP Wrapper 特殊使用的更多相关文章

  1. Linux中TCP wrapper的使用

    Linux中TCP wrapper的使用 tcpwrapper的目的是对那些访问控制功能较弱的服务提供访问控制功能要想了解访问控制就必须先知道服务监听的概念: 服务监听的两种方式: listen    ...

  2. linux TCP Wrappers

    1. TCP Wrapper简介 (出处:http://www.softpanorama.org/Net/Network_security/TCP_wrappers/) (维基百科)TCP Wrapp ...

  3. Linux 防火墙之TCP Wrappers

      1.TCPWrappers  原理 Telnet.SSH.FTP.POP和SMTP等很多网络服务都会用到TCPWrapper,它被设计为一个介于外来服务请求和系统服务回应的中间处理软件.     ...

  4. Linux服务器安全配置

    众所周知,网络安全是一个非常重要的课题,而服务器是网络安全中最关键的环节.Linux被认为是一个比较安全的Internet服务器,作为一种开放源代码操作系统,一旦Linux系统中发现有安全漏洞,Int ...

  5. VsFtpd服务配置简明笔记

    Ftp服务是最常用的文件传输方式,把配置步骤记录下来,以备将来使用. 1.用YUM安装VsFtpd服务:[root@Redis usr]# yum install vsftpd 2.安装完成后启动Vs ...

  6. VsFtpd配置文件详解

    1.默认配置:1>允许匿名用户和本地用户登陆.     anonymous_enable=YES     local_enable=YES2>匿名用户使用的登陆名为ftp或anonymou ...

  7. vsftp 搭建及虚拟账号配置

    安装vsftpd yum -y install vsftpd chkconfig vsftpd on 修改主配置文件 vi /etc/vsftpd/vsftpd.conf # 允许匿名用户登陆,登陆时 ...

  8. 详解Linux目录(目录树详细解释)

    给大家一篇关于Linux目录 方面的详细说明,好好读一下! Linux目录详解(RHEL5.4) linux有四种基本文件系统类型:--普通文件:如文本文件.c语言源代码.shell脚本等,可以用ca ...

  9. /etc/xinetd.conf 和 /etc/xinetd.d/*【新网络服务配置】

    http://blog.csdn.net/kelven2004/article/details/1701930 xinetd 是 inetd 的安全加强版,它内置了自己的 TCP wrapper, 可 ...

随机推荐

  1. 【2016-08-18】转载:总结C++中几种结构体初始化的方法

    作者:Ac_Von 博客地址:http://www.cnblogs.com/vongang/ 文章地址:http://www.cnblogs.com/vongang/archive/2011/07/3 ...

  2. vs win32 & MFC 指针默认位置

    一开始win32指针所在的位置是与debug文件夹同级的.即打开打开改程序的第一个文件夹这一级. MFC指针是在第二个debug下头,就是打开第二个project名词的文件夹下头,e.g., &quo ...

  3. 在MVC的项目中访问静态页面

    MVC在生成项目的时候会生成的WEB-INF底下.这个文件夹下面的文件是受保护的,都会走MVC的流程, 但是我希望在WebContent底下可以使用静态页面, 那么需要进入springmvc-serv ...

  4. Java注释@interface的用法

    转---------- java用  @interface Annotation{ } 定义一个注解 @Annotation,一个注解是一个类.@Override,@Deprecated,@Suppr ...

  5. spring刚开始学习搭建

    下载的软件包地址: http://repo.springsource.org/libs-release-local/org/springframework/spring 用maven进行快速开始: h ...

  6. Jmeter测试JDBC

    Datebase Driver class Database URL MySQL com.mysql.jdbc.Driver jdbc:mysql://host:port/{dbname} Postg ...

  7. profiler加入计划任务

    创建profiler的存储过程: USE [xxxDB] GO /****** Object: StoredProcedure [dbo].[CreateProfile] Script Date: 2 ...

  8. yum -y list java* 查看当前java的版本

    [root@NB ok]# yum -y list java* Loaded plugins: fastestmirror, refresh-packagekit, security Loading ...

  9. My97DatePicker日期范围限制

    1.动态时间范围限制: 可以通过系统给出的动态变量,如%y(当前年),%M(当前月)等来限制日期范围,还可以通过{}进行表达式运算,如:{%d+1}:表示明天. 格式 说明 %y  当前年 %M  当 ...

  10. DedeCMS Error: (PHP 5.3 and above) Please set request_order

    部分使用PHP 5.3的主机可能会有下面的提示: (PHP 5.3 and above) Please set 'request_order' ini value to include C,G and ...