我试图解锁我正在做一些测试的IP.我已经按照网上的教程:
$ sudo /etc/init.d/denyhosts stop
$ sudo vim /etc/deny.hosts
[remove the last line where I can see my IP to clear]
$ cd /var/lib/denyhosts/
$ sudo vim *
[remove any occurences of my IP to clear]
$ sudo /etc/init.d/denyhosts start
Run Code Online (Sandbox Code Playgroud)
此时我的IP出现在/etc/deny.hosts中.我也尝试过:
$ cd /var/lib/denyhosts/
$ echo '123.456.789.122' >> /var/lib/denyhosts/allowed-hosts
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
$ echo 'my.ip.to.clear' >> /etc/hosts.allow
Run Code Online (Sandbox Code Playgroud)
不幸的是,hosts.deny始终优先,拒绝ssh连接,从日志文件中可以看出:
2月10日10:06:24 ks123456 sshd [22875]:拒绝连接123.456.789.122(123.456.789.122)
ref:debian/6.0.4,denyhosts 2.6-10
小智 34
这对Centos有用.按照下面的8个步骤,你应该很高兴.
停止DenyHosts
# services denyhosts stop
从中删除IP地址 /etc/hosts.deny
编辑/var/lib/denyhosts/hosts并删除包含IP地址的行.保存文件.
编辑/var/lib/denyhosts/hosts-restricted并删除包含IP地址的行.保存文件.
编辑/var/lib/denyhosts/hosts-root并删除包含IP地址的行.保存文件.
编辑/var/lib/denyhosts/hosts-valid并删除包含IP地址的行.保存文件.
编辑/var/lib/denyhosts/users-hosts并删除包含IP地址的行.保存文件.
(可选)考虑将IP地址添加到/ var/lib/denyhosts/allowed-hosts
启动DenyHosts
# services denyhosts start
可以在此处找到删除denyhosts条目的说明:http://www.cyberciti.biz/faq/linux-unix-delete-remove-ip-address-that-denyhosts-blocked/ .在Ubuntu中,denyhosts数据文件位于/var/lib/denyhosts.
/var/log/auth.log
它可能会为您提供线索你的问题是什么.我自己遇到了问题,因为我使用sftp在KDE上的Dolphin中保存了一个位置.Dolphin使用您当前的用户名尝试登录,将我的IP添加到hosts.deny文件中.
只需添加应始终有权访问该文件的IP:
/etc/hosts.allow
Run Code Online (Sandbox Code Playgroud)
该条目可能如下所示:
ALL: 30.20.10.0/24
Run Code Online (Sandbox Code Playgroud)
这样,即使最终/etc/hosts.deny也是如此,IP仍然可以访问.
心灵在ALL 之前的IP,我看你忘了,你的echo发言.
参考文献:
小智 7
如果上面的说明没有帮助,可能denyhosts将ip添加到iptables防火墙.
iptables -L -n -v | grep xxx.xxx.xxx.xxx
如果你看到类似的东西:
0 0 DROP all -- * * xxx.xxx.xxx.xxx 0.0.0.0/0
从防火墙中删除所需的IP:
iptables -D INPUT -s xxx.xxx.xxx.xxx -j DROP
并重新启动网络以应用更改:
/etc/init.d/networking restart
| 归档时间: |
|
| 查看次数: |
33963 次 |
| 最近记录: |