AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 53066
Accepted
rwired
rwired
Asked: 2009-08-12 20:08:41 +0800 CST2009-08-12 20:08:41 +0800 CST 2009-08-12 20:08:41 +0800 CST

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

  • 772

编辑(澄清)

              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

在我们的 ISP 将服务器更改为新服务器之前,上述配置运行良好。“完全没问题”是指我可以浏览整个互联网,包括通常在中国被屏蔽的网站。当我登录到另一台服务器上的另一个SSH 会话作为测试时,它仍然可以正常工作(生产网络服务器,我不能为此目的)。在所有情况下,手动 SSH 登录都可以正常工作。

我需要弄清楚为什么它不适用于新服务器,因为该服务器的唯一目的是为我们公司提供此功能。

以前的帖子

我们的服务器提供商最近更改了我们的服务器和 IP 地址。旧服务器的硬盘已移至新服务器,除了 IP 地址更改之外,配置应该是相同的。

在迁移之前,我在 Windows 机器上使用 PuTTY 将网络流量作为 SOCKS 代理通过服务器使用设置为 9870 的动态端口进行隧道传输。迁移之后,我重新配置 PuTTY 以指向新 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

编辑:-

到目前为止,我已经尝试了回复中的所有建议。还是行不通。托管服务器的数据中心的防火墙是否有可能阻止 ssh 隧道?我已经尝试将 D80 作为我在 PuTTY 中的动态端口,但这也不起作用(应该吗?)。该服务器主要是一个网络服务器,但目前我们没有在其上运行任何网站,尽管 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,..N.b].
  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      ............

在我看来,远程服务器接受了端口转发。

进一步编辑:-

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

这立即奏效(Firefox 将 PuTTY 视为 SOCKS 代理),我立即能够访问在我的位置 [中国] 被阻止的站点。

这个测试最有趣的是,下面的受访者在服务器上规定的netstat -an --inet测试也没有显示 127.0.0.1:9870。

我想我需要清楚地指出,我正在为 PuTTY/Firefox 客户端使用 Windows 机器。我正在尝试使用远程 Linux 服务器来传输网络流量,这样我就可以安全地访问在中国被封锁的网站。在我看来,建议的 netstat 测试应该在我的 Windows 机器上运行(在这种情况下,它使用了错误的 netstat 语法)。

ssh putty
  • 6 6 个回答
  • 20885 Views

6 个回答

  • Voted
  1. Best Answer
    James Sneeringer
    2009-08-26T12:30:38+08:002009-08-26T12:30:38+08:00

    应 rwired 的要求,我将我之前的评论重新发布为答案,即:

    远程 Linux 服务器能否建立到 TCP 端口 80 的出站连接?例如,如果你从服务器“telnet www.google.com 80”,你会得到“连接建立”吗?还是它只是挂起?

    预期的含义是某些东西阻塞了出站连接,rwired 发现确实是这种情况。

    • 4
  2. James Sneeringer
    2009-08-12T20:25:23+08:002009-08-12T20:25:23+08:00

    放

    GatewayPorts yes
    

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

    • 2
  3. innaM
    2009-08-12T21:32:02+08:002009-08-12T21:32:02+08:00

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

    编辑:

    netstat 的输出应如下所示:

    tcp        0      0 127.0.0.1:9870          0.0.0.0:*               LISTEN 
    
    • 0
  4. drAlberT
    2009-08-13T00:22:21+08:002009-08-13T00:22:21+08:00

    首先尝试使用 putty 手动建立与服务器的 ssh 连接,从而确保没有服务器 IP 不匹配、防止 MITM 附加等,即 ssh 正在发挥作用,并且可能不会在非交互式 ssh 会话中显示通过腻子。

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

    作为进一步的调试,您可以启用 Putty 日志记录以查看问题的真正位置。

    编辑:在腻子日志中,您发布的唯一让我好奇的信息是终端......我的假设是新服务器无法支持这样的“进化终端”,请尝试将终端降级到古老的 vt100。这可能是问题的可能性很小......

    • 0
  5. hookenz
    2009-08-21T16:08:11+08:002009-08-21T16:08:11+08:00

    您是否检查过您的公钥文件是否实际上位于安装在 ~/.ssh/authorized_keys 下的服务器上

    它可能根本不存在,并且允许您回退到使用纯文本登录,因此看起来它应该可以工作。

    • 0
  6. Nelson
    2009-08-26T14:54:34+08:002009-08-26T14:54:34+08:00

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

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

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

    • 0

相关问题

  • Mac OS X:如何在无头机器上运行 GUI 应用程序

  • Windows SSH 客户端

  • 在 Windows Server 2003 上通过 SSH 启动和停止 Mongrel 服务

  • 隧道 Xbox 网络流量 [关闭]

  • 为什么使用authorized_keys通过ssh自动登录不起作用?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    从 IP 地址解析主机名

    • 8 个回答
  • Marko Smith

    如何按大小对 du -h 输出进行排序

    • 30 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    Windows 中执行反向 DNS 查找的命令行实用程序是什么?

    • 14 个回答
  • Marko Smith

    如何检查 Windows 机器上的端口是否被阻塞?

    • 4 个回答
  • Marko Smith

    我应该打开哪个端口以允许远程桌面?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    MikeN 在 Nginx 中,如何在维护子域的同时将所有 http 请求重写为 https? 2009-09-22 06:04:43 +0800 CST
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    0x89 bash中的双方括号和单方括号有什么区别? 2009-08-10 13:11:51 +0800 CST
  • Martin Hope
    kch 如何更改我的私钥密码? 2009-08-06 21:37:57 +0800 CST
  • Martin Hope
    Kyle Brandt IPv4 子网如何工作? 2009-08-05 06:05:31 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve