在本地网络中无法进行SSH连接


1

今天我意识到一件很奇怪的事:

我的本地网络中有一台服务器(运行Ubuntu Server 12.04.4 LTS),其SSH端口可通过互联网访问(我可以使用它连接到它) ssh my.internet.ip.address )。

但是,我今天才意识到我无法在本地网络中连接它( ssh its.local.ip.address 失败没有错误)。

我检查了 /etc/hosts.deny 并明确地添加了我的电脑 /etc/hosts.allow,但这没有改变任何事情。当然,我也试过重启ssh和整个服务器。没有新的更新。

本地连接失败:

myself@my-desktop ~ $ ssh -v its.local.ip.address
OpenSSH_6.2p2 Ubuntu-6ubuntu0.4, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to its.local.ip.address [its.local.ip.address] port 22.
debug1: Connection established.
debug1: identity file /home/myself/.ssh/id_rsa type -1
debug1: identity file /home/myself/.ssh/id_rsa-cert type -1
debug1: identity file /home/myself/.ssh/id_dsa type -1
debug1: identity file /home/myself/.ssh/id_dsa-cert type -1
debug1: identity file /home/myself/.ssh/id_ecdsa type -1
debug1: identity file /home/myself/.ssh/id_ecdsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2p2 Ubuntu-6ubuntu0.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1.4
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1.4 pat OpenSSH_5*
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
Connection closed by its.local.ip.address
myself@my-desktop ~ $ 

但是,远程连接工作:

myself@my-desktop ~ $ ssh -v my.internet.ip.address
OpenSSH_6.2p2 Ubuntu-6ubuntu0.4, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to my.internet.ip.address [my.internet.ip.address] port 22.
debug1: Connection established.
debug1: identity file /home/myself/.ssh/id_rsa type -1
debug1: identity file /home/myself/.ssh/id_rsa-cert type -1
debug1: identity file /home/myself/.ssh/id_dsa type -1
debug1: identity file /home/myself/.ssh/id_dsa-cert type -1
debug1: identity file /home/myself/.ssh/id_ecdsa type -1
debug1: identity file /home/myself/.ssh/id_ecdsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2p2 Ubuntu-6ubuntu0.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1.4
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1.4 pat OpenSSH_5*
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA [... hidden here ...]
debug1: Host 'my.internet.ip.address' is known and matches the ECDSA host key.
debug1: Found key in /home/myself/.ssh/known_hosts:4
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: password
debug1: Next authentication method: password
myself@my.internet.ip.address's password: 
[ ... everything works just fine ... ]

造成这个问题的原因是什么,更重要的是如何解决?

注意:增加冗长度( ssh -vvv )在两个输出都不同的点上没有显示任何东西。


您还可以检查服务器的/ var / log / *文件以获取相关消息。根据您显示的内容,在验证主机密钥的步骤中似乎失败。你有钥匙吗? its.local.ip.address 在〜/ .ssh / known_hosts?
John1024

我调查了一下 /var/log/auth.log 但那里没有提到我不成功的连接尝试。我没有钥匙 its.local.ip.address~/.ssh/known_hosts
MrD

你尝试过ping或trace路线吗?也许尝试像http这样的其他协议。您还可以在备用端口上运行sshd以排除流量过滤。
chuck

pinghttpsamba 工作正常(但是, http 很慢?...)。 traceroute 说我用第一跳达到目标。 iptables 没有做任何奇怪的事情(只是标准设置),并且没有安装其他防火墙。我不能尝试更改ssh端口,因为服务器被很多人使用(这就是为什么它可以从互联网上访问)。
MrD

你知道为什么吗?
trogper

Answers:


1

服务器决定放弃连接,因此您必须从服务器端调试问题。如果您在服务器上具有“root”访问权限,则可以运行 sshd 交互方式:

/path/to/sshd -ddd -p 42

这将推出一份副本 sshd 在端口42上侦听 - 您可以在调试模式下指定不同的数字。它将在前台运行,接受单个连接并将调试信息打印到终端。

现在与您的客户联系:

ssh -v -p 42 its.local.ip.address

运气好的话,服务器端调试消息应该说明它为什么会丢弃会话。


0

我假设两个捕获中的客户端机器是相同的(即使promts不同) 因为它允许TCP连接,可能它与sshd配置上的反向DNS和/或拒绝策略有关。

尝试关闭服务器端的DNS(在sshd_config上使用DNS =否)并重新启动sshd(kill -1应该足够)


0

据报道,此错误影响了多个用户。

在本地时,请尝试使用ssh -X禁用x转发。

此外,可能需要将最大传输单元[MTU]调整为ssh_server的MTU。

**如果在本地时不起作用,请尝试:

 myself@my-desktop ~ $ ssh -v my.internet.ip.address

如果它可以遍历你的网络,那么回来......

可能是服务器配置错误,检查“允许用户”的sshd_config,以及存储known_host的位置,添加用户“local”的local.ip.address版本。

sshd的副本可以提供帮助

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.