免费注册 查看新帖 |

Chinaunix

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

请问各位大虾,如何限制telnet/ssh登陆Linux系统的IP地址? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-09-19 17:00 |只看该作者 |倒序浏览
想要限制一下登陆到某一个Linux系统上的用户的IP,设定只有某一个范围或者网段的IP地址才能用telnet或者ssh的方式登陆系统,请问该怎么限制?Linux有提供这个功能吗?

论坛徽章:
0
2 [报告]
发表于 2009-09-19 18:19 |只看该作者
iptables

论坛徽章:
7
天蝎座
日期:2013-08-16 23:19:32丑牛
日期:2014-01-08 09:20:14寅虎
日期:2014-01-11 11:03:44午马
日期:2014-04-28 11:02:40天秤座
日期:2014-05-16 23:24:24摩羯座
日期:2014-07-20 10:46:04卯兔
日期:2014-08-08 15:21:41
3 [报告]
发表于 2009-09-19 19:02 |只看该作者
/etc/hosts.allow
/etc/hosts.deny
试试看

论坛徽章:
0
4 [报告]
发表于 2009-09-20 21:47 |只看该作者
只说ssh的,telnet的稍有不同。

1、使用iptables进行主机、域、网络的访问控制:
主机:iptables -A INPUT -s 207.marsaber.com -p tcp --dport 22 -j DROP
域  :iptables -A INPUT -s marsaber.com -p tcp --dport 22 -j DROP 【如果多个,则要写多条规则,不建议】
网络:iptables -A INPUT -s 192.168.0.0/24 -p tcp --dport 22 -j DROP  <-等价->
          iptables -A INPUT -s 192.168.0.0/255.255.255.0 -p tcp --dport 22 -j DROP

2、使用TCP_Wrapper对主机、域、网络的访问控制:
/etc/hosts.deny
        sshd:ALL
/etc/hosts.allow
        sshd:.marsaber.com EXCEPT 207.marsaber.com

3、用户的访问控制:
编辑/etc/ssh/sshd_config,添加:
        DenyUsers marsaber user0*     #marsaber、user0*开头的用户不能远程登录,但其他用户均可登录;
        AllowUsers root marsaber      #root、marsaber可远程登录,其他用户均拒绝登录;
        AllowUsers root@192.168.2.* marsaber@*.marsaber.com
                     #root可从192.168.2.*登录、marsaber可从*.marsaber.com登录,其他用户均拒绝登录;
注意事项:
1、如果多个用户,中间须用空格隔开;
2、不能使用UID、GID;  
详细信息请见man sshd_config

论坛徽章:
5
寅虎
日期:2015-01-20 09:16:52亥猪
日期:2015-01-21 14:43:44IT运维版块每日发帖之星
日期:2015-12-17 06:20:00每日论坛发贴之星
日期:2015-12-17 06:20:00每周论坛发贴之星
日期:2015-12-20 22:22:00
5 [报告]
发表于 2009-09-21 08:41 |只看该作者
iptables ,tcp_wrappers都可以限制的

论坛徽章:
0
6 [报告]
发表于 2009-09-23 22:14 |只看该作者
嗯,iptables和tcp_wrapper都可以,如果情况比较简单的话,推荐tcp_wrapper,如果你的系统要做比较复杂的控制的话,就直接都用iptables。。。

论坛徽章:
0
7 [报告]
发表于 2009-09-24 13:57 |只看该作者
经典!

论坛徽章:
0
8 [报告]
发表于 2009-09-28 09:08 |只看该作者
telnet   用xinetd
ssh    用 hosts.deny  hosts.allow
或者全 iptables
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP