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"),也不行。
求高手解答
TCP Wrapper 特殊使用的更多相关文章
- Linux中TCP wrapper的使用
Linux中TCP wrapper的使用 tcpwrapper的目的是对那些访问控制功能较弱的服务提供访问控制功能要想了解访问控制就必须先知道服务监听的概念: 服务监听的两种方式: listen ...
- linux TCP Wrappers
1. TCP Wrapper简介 (出处:http://www.softpanorama.org/Net/Network_security/TCP_wrappers/) (维基百科)TCP Wrapp ...
- Linux 防火墙之TCP Wrappers
1.TCPWrappers 原理 Telnet.SSH.FTP.POP和SMTP等很多网络服务都会用到TCPWrapper,它被设计为一个介于外来服务请求和系统服务回应的中间处理软件. ...
- Linux服务器安全配置
众所周知,网络安全是一个非常重要的课题,而服务器是网络安全中最关键的环节.Linux被认为是一个比较安全的Internet服务器,作为一种开放源代码操作系统,一旦Linux系统中发现有安全漏洞,Int ...
- VsFtpd服务配置简明笔记
Ftp服务是最常用的文件传输方式,把配置步骤记录下来,以备将来使用. 1.用YUM安装VsFtpd服务:[root@Redis usr]# yum install vsftpd 2.安装完成后启动Vs ...
- VsFtpd配置文件详解
1.默认配置:1>允许匿名用户和本地用户登陆. anonymous_enable=YES local_enable=YES2>匿名用户使用的登陆名为ftp或anonymou ...
- vsftp 搭建及虚拟账号配置
安装vsftpd yum -y install vsftpd chkconfig vsftpd on 修改主配置文件 vi /etc/vsftpd/vsftpd.conf # 允许匿名用户登陆,登陆时 ...
- 详解Linux目录(目录树详细解释)
给大家一篇关于Linux目录 方面的详细说明,好好读一下! Linux目录详解(RHEL5.4) linux有四种基本文件系统类型:--普通文件:如文本文件.c语言源代码.shell脚本等,可以用ca ...
- /etc/xinetd.conf 和 /etc/xinetd.d/*【新网络服务配置】
http://blog.csdn.net/kelven2004/article/details/1701930 xinetd 是 inetd 的安全加强版,它内置了自己的 TCP wrapper, 可 ...
随机推荐
- Sql order by 和 group BY一起使用时需要注意
ORDER BY 子句中的列必须包含在聚合函数或 GROUP BY 子句中. slect * from table group by class,id order by id slect * from ...
- Java IO流题库
一. 填空题 Java IO流可以分为 节点流 和处理流两大类,其中前者处于IO操作的第一线,所有操作必须通过他们进行. 输入流的唯一目的是提供通往数据的通道,程序可以通过这个通道读取数 ...
- android中一个解决办法
E Trace(732): error opening trace file: No such file or directory (2)android api 的版本和模拟器的版本不一致导致的
- poj 3461Oulipo
题目链接:http://poj.org/problem?id=3461 统计字符串出现的次数 #include<cstdio> #include<iostream> #incl ...
- Jquery.Datatables 基本设置的中文注解
$(document).ready(function() { $('#example').dataTable({ "sScrollX": "100%", //表 ...
- 在ubuntu上搭建开发环境6---安装和使用vim及其插件(Pathogen和NERDTree)
2015.09.08 更为详细的配置vim的方法,请参见我的新整理的文章:http://segmentfault.com/a/1190000003722928 Vim安装 命令: sudo apt-g ...
- 攻城狮在路上(肆)How tomcat works(三) 连接器:Connector
在介绍中提到,Catalina中有两个主要的模块:连接器和容器.本章中你将会写一个可以创建更好的请求和响应对象的连接器,用来改进第2章中的程序.一个符合Servlet 2.3和2.4规范的连接器必须 ...
- 面试题之【打印1到最大的N位数】
题目描述:给定一个数字N,打印从1到最大的N位数. 看起来像是很简单的问题(虽然实际也不是很难...)我们很容易写出这样的代码: #include<iostream> #include&l ...
- [JAVA] IOException: Invalid byte 2 of 2-byte UTF-8 sequence(解决办法)
日志打印不全,后台只打印出出标题的异常信息: 先前的日志打印信息:log.debug(e.getMessage()); 后面改成了日志打印信息:log.debug(e); log.debug(e.ge ...
- Linux命令之ar - 创建静态库.a文件和动态库.so
转自:http://blog.csdn.net/eastonwoo/article/details/8241693 用途说明 创建静态库.a文件.用C/C++开发程序时经常用到,但我很少单独在命令行中 ...