免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 5790 | 回复: 13
打印 上一主题 下一主题

[网络管理] 求助:red hat linux怎么限制用户用ssh连接3次失败以后封其IP? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-04-06 17:22 |只看该作者 |倒序浏览
求助:red hat linux怎么限制用户用ssh连接3次失败以后封其IP?

谢谢!
我在网上查了查,好像大家都没说具体的方法。。。

论坛徽章:
1
寅虎
日期:2015-01-23 02:35:47
2 [报告]
发表于 2005-04-06 18:10 |只看该作者

求助:red hat linux怎么限制用户用ssh连接3次失败以后封其IP?

ssh不知道是否有此功能,不过可以写脚本用iptables限制,过一段时间后再自动放开

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
3 [报告]
发表于 2005-05-10 10:04 |只看该作者

求助:red hat linux怎么限制用户用ssh连接3次失败以后封其IP?

今天刚刚看到一个mail上面写的.但是我没有试验过
This is easier:

$IPTABLES -A allowed -p TCP -m state --state ESTABLISHED,RELATED -j ACCEPT

$IPTABLES -A allowed -p TCP --syn -m limit --limit 3/minute --limit-burst 3
-j ACCEPT

$IPTABLES -A allowed -p TCP -j LOG  --log-level "NOTICE" --log-prefix
'[DROP:RATE_LIMIT] '

$IPTABLES -A allowed -p TCP -j REJECT

$IPTABLES -A tcp_packets -p TCP -s 0/0 -d $INET_IP --dport 22 -j allowed


Mojito



>;>; -----Original Message-----
>;>; From: Jeff Rosowski [mailto:rosowskij@ie.ymp.gov]
>;>; Sent: 06 May 2005 14:50
>;>; To: Price, Christopher
>;>; Cc: MPHMedia.Net; secureshell@securityfocus.com
>;>; Subject: RE: Login Attempt Limits
>;>;
>;>; take a look at the following:
>;>;
>;>; http://blog.andrew.net.au/2005/02/17#ipt_recent_and_ssh_attacks
>;>;
>;>; On Thu, 5 May 2005, Price, Christopher wrote:
>;>;
>;
>;>;>; >;
>;>;>; >;         Your proposal could lead to a DoS attack designed to deny large
>;>;>; >; ranges of IP addresses access to your SSHD service by using
>;
>;>; IP spoofing,
>;
>;>;>; >; no?
>;>;>; >;
>;>;>; >; -----Original Message-----
>;>;>; >; From: MPHMedia.Net [mailto:MPHMedia@InfoWest.com]
>;>;>; >; Sent: Thursday, May 05, 2005 8:53 AM
>;>;>; >; To: secureshell@securityfocus.com
>;>;>; >; Subject: Login Attempt Limits
>;>;>; >;
>;>;>; >;
>;>;>; >; I had around 650 failed atttempts on the SSHD server from about 5
>;>;>; >; different IPs yesterday.
>;>;>; >;
>;>;>; >; From prior daily reviews of the log file it is clear that
>;
>;>; the majority
>;
>;>;>; >; of the attempts come from hacked SSHD servers because the attempt
>;>;>; >; username pattern is the same from IPs located in different
>;
>;>; parts of the
>;
>;>;>; >; world (though South Korea seems to have the largest volume of any
>;>;>; >; country).
>;>;>; >;
>;>;>; >; The clear evidence is that the SSHD system fails in a good number of
>;>;>; >; cases.
>;>;>; >;
>;>;>; >; One way to look at this failure is to say that the managers of those
>;>;>; >; servers are not requiring sufficiently random passwords for
>;
>;>; their uesrs.
>;
>;>;>; >;
>;>;>; >; The clear mathematics is that use of 8 byte random
>;
>;>; passwords from the
>;
>;>;>; >; complete available password character set will not be
>;
>;>; cracked (to a very
>;
>;>;>; >;
>;>;>; >; high probability).
>;>;>; >;
>;>;>; >; But the clear reality is that very few passwords are
>;
>;>; selected from the
>;
>;>;>; >; widest possible selection pool and rather from a rather
>;
>;>; small pool of
>;
>;>;>; >; familar words and phrases. This reality combined with a
>;
>;>; high volume of
>;
>;>;>; >; attempts obtains an SSHD system failure at a fairly regular rate, as
>;>;>; >; evidence by the attacking IP variation.
>;>;>; >;
>;>;>; >; I looked briefly at some earlier secureshell pages along
>;
>;>; the lines of my
>;
>;>;>; >;
>;>;>; >; following suggestions with the apparent conclusion that the
>;
>;>;  suggestions
>;
>;>;>; >;
>;>;>; >; have been considered but not implemented for one reason or
>;
>;>; another. They
>;
>;>;>; >;
>;>;>; >; are:
>;>;>; >;
>;>;>; >; 1. When an IP has failed attempts for different usernames
>;
>;>; within a short
>;
>;>;>; >;
>;>;>; >; period block that IP for some number of minutes. This would be done
>;>;>; >; automatically using configuration file parameters. With
>;
>;>; this option I
>;
>;>;>; >; would block an IP for 30 minutes after three failed attempts with
>;>;>; >; different usernames occuring under a minute.
>;>;>; >;
>;>;>; >; 2. Execute an IP block as above when there are 3 root user failures.
>;>;>; >;
>;>;>; >; 3. Execute an IP block as above when there are 5 same user failures.
>;>;>; >;
>;>;>; >; Apparently there is an option to block an IP completely
>;
>;>; after the fact.
>;
>;>;>; >; I am not seeing repeated attempts on subsequent days from
>;
>;>; the same IP.
>;
>;>;>; >; Hence that option would not address the current attack patterns.
>;>;>; >;
>;>;>; >; With the above automatic IP block features, the 650 failed attempts
>;>;>; >; yesterday would have been reduced to less than 20. That
>;
>;>; could be seen as
>;
>;>;>; >;
>;>;>; >; a 5 bit (32 times) reduction in the probability of a
>;
>;>; successful attack
>;
>;>;>; >; and similarly a 5 bit reduction in the number of failed
>;
>;>; SSHD servers.
>;
>;>;>; >;
>;>;>; >; The effective result would be some multiple greater than 5
>;
>;>; bits overall
>;
>;>;>; >; in that the hacked server pool would decline by a 5 bit
>;
>;>; multiple. That
>;
>;>;>; >; is, the attack volume originates from already hacked servers meaning
>;>;>; >; that the overall attack volume derives from at least two
>;
>;>; layers to which
>;
>;>;>; >;
>;>;>; >; 5 bit attenuation could be applied. I would consider an
>;
>;>; obvious 5 bit
>;
>;>;>; >; attenuation very useful, but an apparent compounded 5 bit
>;
>;>; attenuation
>;
>;>;>; >; seems to argue for immediate implementation. Looked at
>;
>;>; another way, the
>;
>;>;>; >; effective randomness of the currently used password pool
>;
>;>; should increase
>;
>;>;>; >;
>;>;>; >; by 5 to, say, 15 bits. Or we could say that overall SSHD
>;
>;>; security would
>;
>;>;>; >; be increased by a similar degree.
>;>;>; >;
>;>;>; >; Whatever the implementation difficulties, the design is clear.
>;>;>; >;
>;>;>; >; Save failures by IP in the above categories and execute the
>;
>;>; block using
>;
>;>;>; >; new configuration file parameters.
>;>;>; >;
>;>;>; >; Neil Nelson
>;>;>; >;
>;>;>; >;
>;>;>; >;
>;>;>; >;

论坛徽章:
0
4 [报告]
发表于 2005-05-10 10:14 |只看该作者

求助:red hat linux怎么限制用户用ssh连接3次失败以后封其IP?

$IPTABLES -A allowed -p TCP --syn -m limit --limit 3/minute --limit-burst 3
-j ACCEPT

这个好像不行吧?
这个的意思是当TCP的syn请求达到3个以后,允许每分钟再允许3个,那么其他的呢?
$IPTABLES -A allowed -p TCP -j REJECT
都被REJECT了,这样恐怕连正常的ssh请求都无法进行了,如果有人不断syn连结ssh,恐怕管理员自己也无法正常连结,要跟那个人抢1分钟内的那3次才可以……

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
5 [报告]
发表于 2005-05-10 11:12 |只看该作者

求助:red hat linux怎么限制用户用ssh连接3次失败以后封其IP?

这个东西我没有试验过.只是今天看到的.另外我估计需要限制目标地址的来源.当然了.如果是来源的地址是管理员的ip的话肯定是也被限制了.
这个事情经常出现在一个单位管理idc里面的机器.但是这个单位的管理员和攻击人员使用一个公网地址进行联军大奥idc. 如果是被拒绝了就会出现真正的管理员连接不到服务器的现象.所以希望管理员能够有一个单独的地址做nat 这样就好了 这几天有很多人都是在使用ssh 不断的尝试登陆.

论坛徽章:
0
6 [报告]
发表于 2005-05-10 11:32 |只看该作者

求助:red hat linux怎么限制用户用ssh连接3次失败以后封其IP?

需要写脚本:

可以根据/var/log/secure中:
Failed password for illegal user root from 219.1.2.5 port 10284 ssh2
的行数,也就是登录次数。
再用iptables来限制ip地址219.1.2.5登录。加上时间限制,可以过一段时间再开放。

论坛徽章:
0
7 [报告]
发表于 2005-05-10 12:25 |只看该作者

求助:red hat linux怎么限制用户用ssh连接3次失败以后封其IP?

呵呵,感觉太悬了,上次我写了一个封ftp的shell,结果自己没注意,超出了连接限制数,把自己关外面了
不过,好在封的是ftp,如果真自己输错了3次ssh的密码,被关在ssh外面,那就麻烦了

论坛徽章:
0
8 [报告]
发表于 2005-05-10 12:52 |只看该作者

求助:red hat linux怎么限制用户用ssh连接3次失败以后封其IP?

原帖由 "platinum" 发表:
呵呵,感觉太悬了,上次我写了一个封ftp的shell,结果自己没注意,超出了连接限制数,把自己关外面了
不过,好在封的是ftp,如果真自己输错了3次ssh的密码,被关在ssh外面,那就麻烦了


可以30分钟释放一次,不过自己输错3次密码,也太................
然后把豆腐的命令,加个ssh端口
用shell写个教本,分析一下登陆日志,在crontab跑一下就行

论坛徽章:
0
9 [报告]
发表于 2005-05-10 13:00 |只看该作者

求助:red hat linux怎么限制用户用ssh连接3次失败以后封其IP?

原帖由 "南非蜘蛛" 发表:

然后把豆腐的命令,加个ssh端口

全封岂不是更好?

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
10 [报告]
发表于 2005-05-10 13:33 |只看该作者

求助:red hat linux怎么限制用户用ssh连接3次失败以后封其IP?

原帖由 "platinum" 发表:

全封岂不是更好?


最好的方法是不是任何ssh之类的东西连接一个串口上去操作.这样连键盘鼠标显示器都不用了.我有一个过去的mmx166的机器就是这么使用的.用了快一年什么事情都没有. :em11:
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP