我们在办公室中安装了一个相当老的SUSELinux10.1 (i586)。
问题很简单:我可以成功地从同一个LAN中的机器(192.168.1.0)中获得ssh,但不能从另一个LAN中的机器(10.23.0.0)获得ssh。
SuSE具有SSH服务器openssh-4.2p1-18.12。我已经排除了防火墙、hosts.allow和hosts.deny文件。
当我的ssh登录尝试失败时,日志如下所示:
客户机上的
$ ssh -vvv 192.168.1.5
OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to 192.168.1.5 [192.168.1.5] port 22.
debug1: Connection established.
debug1: identity file /home/nbuild/.ssh/identity type -1
debug1: identity file /home/nbuild/.ssh/identity-cert type -1
debug1: identity file /home/nbuild/.ssh/id_rsa type -1
debug1: identity file /home/nbuild/.ssh/id_rsa-cert type -1
debug1: identity file /home/nbuild/.ssh/id_dsa type -1
debug1: identity file /home/nbuild/.ssh/id_dsa-cert type -1
服务器上的
Aug 21 16:34:25 serverhost sshd[20736]: debug3: fd 4 is not O_NONBLOCK
Aug 21 16:34:25 serverhost sshd[20736]: debug1: Forked child 20739.
Aug 21 16:34:25 serverhost sshd[20736]: debug3: send_rexec_state: entering fd = 7 config len 403
Aug 21 16:34:25 serverhost sshd[20736]: debug3: ssh_msg_send: type 0
Aug 21 16:34:25 serverhost sshd[20736]: debug3: send_rexec_state: done
Aug 21 16:34:25 serverhost sshd[20739]: debug1: rexec start in 4 out 4 newsock 4 pipe 6 sock 7
Aug 21 16:34:25 serverhost sshd[20739]: debug1: inetd sockets after dupping: 3, 3
Aug 21 16:34:25 serverhost sshd[20739]: debug3: Normalising mapped IPv4 in IPv6 address
Aug 21 16:34:25 serverhost sshd[20739]: Connection from 10.23.1.11 port 44340
服务器上的上述日志是在启用DEBUG3日志级别时使用的。但是,对于默认的日志级别(INFO),服务器记录的唯一内容是:
Aug 21 16:38:32 serverhost sshd[20749]: Did not receive identification string from 10.23.1.11
有什么暗示吗?我觉得我已经什么都试过了。
更新:如果这件事重要的话,不能使用ssh的机器在另一个VLAN中。我试过CentOS 6.5和Ubuntu。
发布于 2014-08-21 07:14:30
听起来好像您还没有与服务器交换密钥。你试过用用户名/密码连接吗?
你可以用这样的东西交换钥匙:
ssh-copy-id <Username>@<RemoteHost>
发布于 2014-08-29 05:51:39
我已经解决了这个问题。这似乎是某种奇怪的网络/路由问题,即两个子网之间来回的数据包通过不同的路由。
192.168.1.1是我们的办公室路由器(思科RV042),连接我们与互联网。192.168.1.200是我们办公室的智能、管理、VLAN感知的思科交换机(SG300),它将我们彼此连接,并连接到路由器。该交换机在系统模式L3中运行,这意味着它也可以充当VLAN之间的路由器。它配置了两个VLAN - VLAN 1(默认)和VLAN 2。从192.168.1.x开始的in主机在VLAN 1中,10.23.x.x在VLAN 2中。
traceroute指出,VLAN 1中的数据包经过3次跳才到达VLAN 2:
[root@192.168.1.5]# traceroute -n 10.23.1.11
traceroute to 10.23.1.11 (10.23.1.11), 30 hops max, 40 byte packets
1 192.168.1.1
2 192.168.1.200
3 10.23.1.11
而来自VLAN 2的数据包经过两个跳才到达VLAN 1:
[root@10.23.1.11]# traceroute -n 192.168.1.5
traceroute to 192.168.1.5 (192.168.1.5), 30 hops max, 60 byte packets
1 10.23.1.1
2 192.168.1.5
案例1中的
)
主机192.168.1.5具有默认网关192.168.1.1 (我们的办公路由器)。所以,一个数据包首先被发送到路由器,然后路由器将它转发到192.168.1.200 (我们的智能交换机),因为我已经显式地配置了一个静态规则,否则什么都不会发生(我想,在默认情况下,10.0.0.0网络是私有的,不可路由的,或者什么的,我不是网络专家)。从这里开始,我们的智能交换机起到了路由器的作用(L3,还记得吗?),将数据包转发到其最终目的地10.23.1.11。
案例2中的
)
主机10.23.1.11具有默认网关10.23.1.1。这也是交换机,但这一次VLAN 2中的另一个接口。因此,数据包首先击中交换机和交换机,就像上面的路由器一样,通过它的其他接口引导数据包到VLAN 1的适当主机192.168.1.5。这一次我们有一个快捷方式绕过路由器。
我的一位同事建议我们让案例1和案例2的行为类似,看看会发生什么,即消除案例1中的多余跳转,跳过路由器。因此,我在案例1中更改了默认网关。169.254.0.0和127.0.0.0的条目已经在那里了,不知道为什么,它是一个遗留系统:
[root@192.168.1.5]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
[root@192.168.1.5]# route add default gw 192.168.1.200
[root@192.168.1.5]# route del default gw 192.168.1.1
[root@192.168.1.5]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 192.168.1.200 0.0.0.0 UG 0 0 0 eth0
因此,现在默认网关从192.168.1.1 (路由器)更改为192.168.1.200 (交换机),而发送给VLAN 2中主机的数据包不必转到路由器,然后返回交换机,但就像第2种情况下的快捷方式一样:
[root@192.168.1.5]# traceroute -n 10.23.1.11
traceroute to 10.23.1.11 (10.23.1.11), 30 hops max, 40 byte packets
1 192.168.1.200
2 10.23.1.11
最重要的是(同时也令人惊讶),SSH问题自行解决了!现在我可以从192.168.1.5到10.23.1.11。我仍然认为SSH不应该关心数据包通过的地方,但是去想想.
对于上面的路由设置,不利的一面是,如果主机192.168.1.5想访问互联网,它必须先通过交换机,然后路由器,最后退出。这增加了一个不必要的跳转,我没有优化它(参见下面的说明)。
我尝试为目的地10.23.0.0添加网关192.168.1.200,而没有删除192.168.1.1,如下所示:
[root@192.168.1.5]# route add 10.23.0.0 gw 192.168.1.200
[root@192.168.1.5]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.23.0.0 192.168.1.200 255.255.255.255 UGH 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
其意图是,只有发送给VLAN 2的数据包才能通过192.168.1.200,而用于Internet的数据包将通过192.168.1.1,但这是行不通的。发送给LAN 10.23.0.0的数据包仍然通过192.168.1.1,SSH仍然无法工作。
我尝试用另一个命令添加192.168.1.200:
[root@192.168.1.5]# route add 10.23.0.0 gw 192.168.1.200 netmask 255.255.0.0
route: netmask 0000ffff doesn't make sense with host route
还是没有运气。
最后,我尝试同时保留两个默认网关,即添加.200而不删除.1。
[root@192.168.1.5]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
0.0.0.0 192.168.1.200 0.0.0.0 UG 0 0 0 eth0
我不知道这是不是健康的事情。我不知道操作系统如何决定每次在哪里发送数据包,因为路由表中的最后两个条目似乎是相同的。行为似乎是随机的。网络专家们,请解释一下。
https://serverfault.com/questions/623089
复制