服务器更改后,使用PuTTY的SSH隧道不再工作

编辑(澄清)

Windows Client Remote Linux Server |----------------------------------| |---------------------| ____________ ____________ ____________ | | | | | | | Firefox | -------> | PuTTY | -------> | sshd | ---> (The Internet) |____________| |____________| |____________| Network settings: Interactive SSH Session sshd_config Manual Proxy: (manual login) posted below SOCKS Host: Configuration Settings: localhost:9870 Connection|SSH|Tunnels set to D9870 

上述configuration工作完全正常,直到我们的ISP将服务器更改为新的。 我的意思是我可以浏览整个互联网,包括通常在中国封锁的网站。 当我login另一个服务器上的另一个 SSH会话作为一个testing(一个生产networking服务器,而不是我可以为此目的)时,它仍然工作得很好。 在任何情况下,手动SSHlogin都是正常的。

我需要弄清楚为什么它不能与新的服务器一起工作,因为这个服务器的唯一目的是为我们公司提供这个function。

以前的post

我们的服务器供应商最近更改了我们的服务器和IP 旧服务器上的硬盘被移动到了新的硬盘上,并且configuration应该与IP地址更改不同。

在移动之前,我使用Windows上的PuTTY通过使用dynamic端口设置为9870的服务器将networkingstream量作为SOCKS代理进行隧道传输。迁移后,我重新configurationPuTTY以指向新的IP。 但隧道不再工作(在Firefox中请求页面时超时)。

我没有访问旧的服务器。 但新服务器上的sshd_config是:

 # $OpenBSD: sshd_config,v 1.73 2005/12/06 22:38:28 reyk Exp $ # This is the sshd server system-wide configuration file. See # sshd_config(5) for more information. # This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin # The strategy used for options in the default sshd_config shipped with # OpenSSH is to specify options with their default value where # possible, but leave them commented. Uncommented options change a # default value. #Port 22 #Protocol 2,1 Protocol 2 #AddressFamily any #ListenAddress 0.0.0.0 #ListenAddress :: # HostKey for protocol version 1 #HostKey /etc/ssh/ssh_host_key # HostKeys for protocol version 2 #HostKey /etc/ssh/ssh_host_rsa_key #HostKey /etc/ssh/ssh_host_dsa_key # Lifetime and size of ephemeral version 1 server key #KeyRegenerationInterval 1h #ServerKeyBits 768 # Logging # obsoletes QuietMode and FascistLogging #SyslogFacility AUTH SyslogFacility AUTHPRIV #LogLevel INFO # Authentication: #LoginGraceTime 2m #PermitRootLogin yes #StrictModes yes #MaxAuthTries 6 #RSAAuthentication yes #PubkeyAuthentication yes #AuthorizedKeysFile .ssh/authorized_keys # For this to work you will also need host keys in /etc/ssh/ssh_known_hosts #RhostsRSAAuthentication no # similar for protocol version 2 #HostbasedAuthentication no # Change to yes if you don't trust ~/.ssh/known_hosts for # RhostsRSAAuthentication and HostbasedAuthentication #IgnoreUserKnownHosts no # Don't read the user's ~/.rhosts and ~/.shosts files #IgnoreRhosts yes # To disable tunneled clear text passwords, change to no here! #PasswordAuthentication yes #PermitEmptyPasswords no PasswordAuthentication yes # Change to no to disable s/key passwords #ChallengeResponseAuthentication yes ChallengeResponseAuthentication no # Kerberos options #KerberosAuthentication no #KerberosOrLocalPasswd yes #KerberosTicketCleanup yes #KerberosGetAFSToken no # GSSAPI options #GSSAPIAuthentication no GSSAPIAuthentication yes #GSSAPICleanupCredentials yes GSSAPICleanupCredentials yes # Set this to 'yes' to enable PAM authentication, account processing, # and session processing. If this is enabled, PAM authentication will # be allowed through the ChallengeResponseAuthentication mechanism. # Depending on your PAM configuration, this may bypass the setting of # PasswordAuthentication, PermitEmptyPasswords, and # "PermitRootLogin without-password". If you just want the PAM account and # session checks to run without PAM authentication, then enable this but set # ChallengeResponseAuthentication=no #UsePAM no UsePAM yes # Accept locale-related environment variables AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT AcceptEnv LC_IDENTIFICATION LC_ALL #AllowTcpForwarding yes #GatewayPorts no #X11Forwarding no X11Forwarding yes #X11DisplayOffset 10 #X11UseLocalhost yes #PrintMotd yes #PrintLastLog yes #TCPKeepAlive yes #UseLogin no #UsePrivilegeSeparation yes #PermitUserEnvironment no #Compression delayed #ClientAliveInterval 0 #ClientAliveCountMax 3 #ShowPatchLevel no #UseDNS yes #PidFile /var/run/sshd.pid #MaxStartups 10 #PermitTunnel no # no default banner path #Banner /some/path # override default of no subsystems Subsystem sftp /usr/libexec/openssh/sftp-server 

编辑:-

到目前为止,我已经尝试了所有的build议。 还是行不通。 在托pipe服务器的数据中心的防火墙是否有可能阻止ssh-tunnel? 我已经尝试D80作为我的dynamic端口在腻子,但这也不起作用(应?)。 服务器主要是一个Web服务器,但目前我们没有运行任何网站,虽然Apache正在运行。

我已经看了putty.log,虽然我不能理解它,但有以下部分:

 Event Log: Opened channel for session Event Log: Local port 9870 SOCKS dynamic forwarding Outgoing packet type 98 / 0x62 (SSH2_MSG_CHANNEL_REQUEST) 00000000 00 00 00 00 00 00 00 07 70 74 79 2d 72 65 71 01 ........pty-req. 00000010 00 00 00 05 78 74 65 72 6d 00 00 00 50 00 00 00 ....xterm...P... 00000020 18 00 00 00 00 00 00 00 00 00 00 00 10 03 00 00 ................ 00000030 00 7f 80 00 00 96 00 81 00 00 96 00 00 ............. Outgoing raw data 00000000 ed 9b 4d c5 0c 7f c4 67 e7 ad 96 3f 5a fd 26 fb ..M....g...?Z.&. 00000010 48 27 cd e9 b9 bd 4f 52 2c e0 d3 4e de 62 5d ab H'....OR,..Nb]. 00000020 c0 10 51 a9 80 8e 68 9c 6d 4c bf ab 75 e9 e1 7a ..Q...h.mL..u..z 00000030 bf 66 e3 ff 6f 94 fe f9 9e 78 3d b5 e0 a6 8c fd .f..o....x=..... 00000040 61 5b 69 b4 ec 7c 30 a0 29 87 9c 2c d2 94 57 bd a[i..|0.)..,..W. 00000050 6e 4b 9c 6c d0 39 cc 46 66 3c 5d 7d dc 37 76 cf nK.l.9.Ff<]}.7v. 00000060 9b c7 24 46 ..$F Incoming raw data 00000000 30 ae 0c b2 25 a9 c1 73 47 1f 2d 6a 5e 5b 7f 88 0...%..sG.-j^[.. 00000010 99 99 0c 28 ff 87 5b 0e 82 61 f5 33 81 3d 8a 7d ...(..[..a.3.=.} 00000020 d6 b7 3d 6f ..=o Incoming packet type 99 / 0x63 (SSH2_MSG_CHANNEL_SUCCESS) 00000000 00 00 01 00 ............ 

对于我来说,哪个端口转发看起来像被远程服务器所接受。

进一步编辑: –

我已经尝试连接到另一台服务器,我经常SSH与PuTTY(D9870)中完全相同的SSH隧道设置,

这个工作可以立即生效(Firefox会把它看作是一个SOCKS代理),我立刻就可以访问被我的位置封锁的网站。

这个testing最有趣的是服务器上的受访者规定的netstat-an -inettesting也没有显示127.0.0.1:9870。

我想我需要清楚地指出,我正在为PuTTY / Firefox客户端使用Windows机器。 而且我正在试图使用远程Linux服务器来通过networking传输,所以我可以安全地访问被阻止在中国的网站。 在我看来,build议的netstattesting应该在我的Windows机器上运行(在这种情况下,它使用错误的netstat语法)。

在rwired的请求,我重新发布我以前的评论作为答案,这是:

远程Linux服务器可以build立到TCP端口80的出站连接吗? 例如,如果您从服务器“telnet http://www.google.com 80”,您是否获得“build立连接”? 或者只是挂起?

意图的含义是有些东西阻碍了出站连接,这个连接发生的确是这样。

 GatewayPorts yes 

在你的sshd_config 。 它默认为“no”,这会阻止您使用远程端口转发( ssh -R )到远程SSH服务器本身以外的任何地址。

恕我直言,你的sshd_config看起来不错。 也许sshd是通过设置AllowTcpForwarding为no的附加命令行参数启动的? 如果您在服务器上执行“netstat -an –inet”,是否显示转发的端口? 你确定你的袜子代理工作正常吗?

编辑:

netstat的输出应该如下所示:

 tcp 0 0 127.0.0.1:9870 0.0.0.0:* LISTEN 

你有没有检查公钥文件是否在〜/ .ssh / authorized_keys下安装的服务器上

这可能是根本不存在的,并且允许你回退到使用纯文本login,所以看起来应该是工作。

首先尝试手动使用腻子到服务器的SSH连接,从而确保没有服务器IP不匹配,MITM附加预防等,这是ssh正在采取行动,可能不会显示在一个非交互式的SSH会话通过腻子。

如果这工作正常,那么你真的必须看到通过netstat监听localhost端口上的连接隧道,如果不是我怀疑这个问题不会被ssh限制

作为进一步的debugging,您可以启用Putty日志logging以查看问题的真实位置。

编辑:在腻子日志你张贴唯一的信息让我好奇的是terminal…我的假设是,新的服务器不能支持这样一个“evolutedterminal”,尝试降级terminal到古代vt100。 这可能是一个相当微弱的问题。

当服务器发生变化时,您应该已经收到有关新主机密钥的警告。 你应该已经接受了新密钥,可能会先清除旧密钥。 是你做的吗? 我相信,如果你有错误的主机密钥ssh有时会允许你打开一个交互式会话,但不会转发端口

PuTTY 将其密钥存储在HKEY_CURRENT_USER \ Software \ SimonTatham \ PuTTYregistry中(这与OpenSSH中的known_hosts文件相似)。 您可以尝试从那里手动删除密钥。 或者,如果您想完全重置PuTTY的设置并重新开始,请尝试使用putty -cleanup 。

如果这不是你的问题,你也可以使用详细的login进一步debugging。 尝试运行“plink -v主机名”并查看错误。 您也可以通过plink手动创build隧道 ; 您可能需要尝试这些选项才能使错误出现在plink中。 作为最后的手段,从plink -v发布日志,我们可以进一步debugging。