时间:2015-06-12 17:12:31 作者:qipeng 来源:系统之家 1. 扫描二维码随时看资讯 2. 请使用手机浏览器访问: https://m.xitongzhijia.net/xtjc/20150612/50761.html 手机查看 评论 反馈
3、启动服务
注意修改完后:
#service xinetd restart
才能让刚才的更改生效。
需求:需要用hosts.deny限制用户通过ssh登录
在/etc/hosts.deny中加入
sshd: all
在/etc/hosts.allow中加入
sshd:all #拒绝所有的ip链接ssh服务
在其他服务器上尝试链接该服务器,却发现还是正常链接
继续找问题,又从网上得知, /etc/hosts.allow 与 /etc/hosts.deny 只对调用了 tcp_wrappers 的才起作用。若是源代码编译的,看看编译时是否寻找了 libwrap.so
在起效果机器下,执行如下命令:
[root@zt ~]# ldd /usr/sbin/sshd | grep libwrap.so
libwrap.so.0 =》 /lib64/libwrap.so.0 (0x00002ba28edcc000)
在不起效果机器下,却找不到libwrap.so
在生效的机器上执行:
rpm -qf /lib64/libwrap.so.0 结果如下:
tcp_wrappers-7.6-40.7.el5
在不生效的机器上
yum install -y tcp_wrappers
安装后,用ldd /usr/sbin/sshd | grep libwrap.so 还是没有内容
在不生效机器上,继续
yum list |grep openssh 结果:
openssh.x86_64 5.3p2-24.el5 installed
openssh-clients.x86_64 5.3p2-24.el5 installed
openssh-server.x86_64 5.3p2-24.el5 installed
openssh.x86_64 5.3p2-41.el5_5.1 updates
openssh-askpass.x86_64 5.3p2-41.el5_5.1 updates
openssh-clients.x86_64 5.3p2-41.el5_5.1 updates
openssh-server.x86_64 5.3p2-41.el5_5.1 updates
于是,执行:
yum update -y openssh
再次执行:
ldd /usr/sbin/sshd | grep libwrap.so
有结果显示了。
别的服务器链接该服务器,也会报下面的错误
ssh_exchange_identification: Connection closed by remote host
另一种,也是大家常用的iptalbes来限制IP访问网站
只允许指定的一个IP访问服务器
vi /etc/sysconfig/iptables
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -s 165.232.121.17 -j ACCEPT
-A INPUT -j DROP
COMMIT
发表评论
共0条
评论就这些咯,让大家也知道你的独特见解
立即评论以上留言仅代表用户个人观点,不代表系统之家立场