ssh无法登录的问题

作者: 2hei 发表于2008年1月25日 13:42
版权声明: 可以转载, 转载时务必以超链形式标明文章原始出处和作者信息及版权声明
http://www.2hei.net/mt/2008/01/ssh-iptables-hosts-allow-deny.html

今天遇到朋友问我这样一个问题,托管的服务器ssh不好用了,无法登录。

症状是: ssh 端口可以telnet 通,但是就是无法远程登录上去,用同网段的另外一台服务器可以登录上去,

比较奇怪,于是让我帮忙看看。

我中转登上去看了一下,经历了如下步骤:

  • iptables没有问题,iptables -vnL 看一了下规则,也没有问题,保险起见我把iptables停掉了,
  • 检查ssh服务,看了sshd的配置,重启服务,未果。
  • 查看了系统日志,检测一下是否被人入侵了,/var/log 全面检测,发现没有什么异样。

这就奇怪了,难道要我重装sshd吗?

  • 查看/etc/hosts.allow 和/etc/hosts.deny ,原来问题再这里,

里面有类似这样的设置:

[root@2hei.net ]# more /etc/hosts.allow
#
# hosts.allow   This file describes the names of the hosts which are
#               allowed to use the local INET services, as decided
#               by the '/usr/sbin/tcpd' server.
#
sshd:192.168.1.100:allow
vsftpd:192.168.1.100:allow

[root@2hei.net ]# more /etc/hosts.deny
#
# hosts.deny    This file describes the names of the hosts which are
#               *not* allowed to use the local INET services, as decided
#               by the '/usr/sbin/tcpd' server.
#
# The portmap line is redundant, but it is left to remind you that
# the new secure portmap uses hosts.deny and hosts.allow.  In particular
# you should know that NFS uses portmap!
sshd:ALL:deny
vsftpd:ALL:deny

 

把/etc/hosts.deny的注释掉,或者把/etc/hosts.allow加上允许的IP即可。

总结一下:

iptables和hosts文件共同使用是,注意ip段。

另外hosts并不能禁掉ssh的端口,其他人虽然无法登陆,但是telnet ssh端口却可以发现服务开着,所以iptables还是有必要使用的。

 

| | Comments (0) | TrackBacks (0)

发表一个评论

关于这篇文章

这篇文章由2hei2008年1月25日 13:42发布.

上一篇:China 省份,城市三级联动数据库

下一篇:java proxy visit url

回到首页 或者查看归档文章

  • Powered by FeedBurner
  • Add to Google Reader or Homepage
  • Add to My AOL
  • Subscribe in NewsGator Online
  • del.icio.us/2heidel.icio.us/2hei
  • Subscribe to feed feeds