SSH 本地端口转发在连接时挂起

SSH 本地端口转发在连接时挂起

我正在尝试建立本地端口转发,但遇到了两个困难:

使用时ssh -vL 1083:127.0.0.1:22 akveton2@cms904usr -N

命令时,我收到此错误:

绑定:无法分配请求的地址

我用 Google 搜索了一下,发现如果调试输出中包含此行,则表示它正在尝试使用 IPv6 进行连接:

debug1:本地转发监听::1 端口 1083。

此后,我已将 -4 参数添加到命令中,因此绑定错误不再被打印,但现在输入密码后连接会挂起。问题可能出在哪里?以下是日志:

[akveton@lxplus070 ~]$ ssh -vL 1083:127.0.0.1:1083 akveton2@cms904usr -N
OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to cms904usr [137.138.251.206] port 22.
debug1: Connection established.
debug1: identity file /afs/cern.ch/user/a/akveton/.ssh/identity type -1
debug1: identity file /afs/cern.ch/user/a/akveton/.ssh/identity-cert type -1
debug1: identity file /afs/cern.ch/user/a/akveton/.ssh/id_rsa type -1
debug1: identity file /afs/cern.ch/user/a/akveton/.ssh/id_rsa-cert type -1
debug1: identity file /afs/cern.ch/user/a/akveton/.ssh/id_dsa type -1
debug1: identity file /afs/cern.ch/user/a/akveton/.ssh/id_dsa-cert type -1
debug1: identity file /afs/cern.ch/user/a/akveton/.ssh/id_ecdsa type -1
debug1: identity file /afs/cern.ch/user/a/akveton/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 1.99, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.3
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-sha1 none
debug1: kex: client->server aes128-ctr hmac-sha1 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<2048<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'cms904usr' is known and matches the RSA host key.
debug1: Found key in /afs/cern.ch/user/a/akveton/.ssh/known_hosts:13
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
Server not found in Kerberos database

debug1: Authentications that can continue: gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: password
akveton2@cms904usr's password: 
debug1: Authentication succeeded (password).
debug1: Local connections to LOCALHOST:1083 forwarded to remote address 127.0.0.1:1083
debug1: Local forwarding listening on 127.0.0.1 port 1083.
debug1: channel 0: new [port listener]
debug1: Local forwarding listening on ::1 port 1083.
bind: Cannot assign requested address
debug1: Requesting [email protected]
debug1: Entering interactive session.
^Cdebug1: channel 0: free: port listener, nchannels 1
Killed by signal 2.
[akveton@lxplus070 ~]$ ssh -v4L 1083:127.0.0.1:22 akveton2@cms904usr -N^C
[akveton@lxplus070 ~]$ ssh -v4L 1083:127.0.0.1:1083 akveton2@cms904usr -N
OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to cms904usr [137.138.251.206] port 22.
debug1: Connection established.
debug1: identity file /afs/cern.ch/user/a/akveton/.ssh/identity type -1
debug1: identity file /afs/cern.ch/user/a/akveton/.ssh/identity-cert type -1
debug1: identity file /afs/cern.ch/user/a/akveton/.ssh/id_rsa type -1
debug1: identity file /afs/cern.ch/user/a/akveton/.ssh/id_rsa-cert type -1
debug1: identity file /afs/cern.ch/user/a/akveton/.ssh/id_dsa type -1
debug1: identity file /afs/cern.ch/user/a/akveton/.ssh/id_dsa-cert type -1
debug1: identity file /afs/cern.ch/user/a/akveton/.ssh/id_ecdsa type -1
debug1: identity file /afs/cern.ch/user/a/akveton/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 1.99, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.3
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-sha1 none
debug1: kex: client->server aes128-ctr hmac-sha1 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<2048<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'cms904usr' is known and matches the RSA host key.
debug1: Found key in /afs/cern.ch/user/a/akveton/.ssh/known_hosts:13
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
Server not found in Kerberos database

debug1: Authentications that can continue: gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: password
akveton2@cms904usr's password: 
debug1: Authentication succeeded (password).
debug1: Local connections to LOCALHOST:1083 forwarded to remote address 127.0.0.1:1083
debug1: Local forwarding listening on 127.0.0.1 port 1083.
debug1: channel 0: new [port listener]
debug1: Requesting [email protected]
debug1: Entering interactive session.

其他一些症状:

如果我打开两个终端,一个用于执行隧道,另一个用于 curl:

curl --socks5 localhost:1083 http://cms904usr在第二个终端输入,得到:

curl:(7)无法接收 SOCKS5 连接请求确认。

同时,第一个终端打印出

通道 1:打开失败:连接失败:连接被拒绝

如果我输入curl --proxy localhost:1083 http://cms904usr第二个终端,我会得到

curl:(52)服务器回复为空

第一个终端里什么也没有。

如果我尝试使用 Firefox 连接,我会得到

代理服务器拒绝连接

相关内容