使用主通道进行 SSH 端口转发

使用主通道进行 SSH 端口转发

我正在尝试在现有主通道上设置反向端口转发,但似乎不起作用,我不确定原因。我按如下方式设置主通道:

ssh -MN -oControlPath=/tmp/mycontrolpath hostname

我尝试像这样打开反向端口转发:

ssh -oControlPath=/tmp/mycontrolpath -NR 10017:127.0.0.1:10017 hostname

但第二个过程失败,输出

stdin: is not a tty

并且远程主机上没有打开任何端口转发。这似乎成为协议支持的功能(无论如何,根据 RFC),但我尝试使用它却无济于事。有人让它工作了吗?

客户端SSH版本为OpenSSH_5.3p1 Debian-3ubuntu6,OpenSSL 0.9.8k 25 Mar 2009,连接到服务器上的OpenSSH_5.5p1 Debian-6,OpenSSL 0.9.8o 01 Jun 2010。

更新

运行带有 -vvvv 的 port-forward 命令将得到以下输出:

OpenSSH_5.3p1 Debian-3ubuntu6, OpenSSL 0.9.8k 25 Mar 2009
debug1: Reading configuration data /home/regularfry/.ssh/config
debug1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug3: ssh_msg_send: type 2
debug3: ssh_msg_recv entering
debug3: ssh_msg_send: type 2
debug3: ssh_msg_recv entering
stdin: is not a tty

主套接字进程相应输出的相关部分如下所示:

debug3: fd 5 is not O_NONBLOCK
debug3: ssh_msg_recv entering
debug3: ssh_msg_send: type 2
debug3: ssh_msg_recv entering
debug3: muxserver_accept_control: receiving 2 env vars
debug2: muxserver_accept_control: accepted tty 0, subsys 0, cmd
debug2: muxserver_accept_control: got fds stdin 6, stdout 7, stderr 8
debug3: ssh_msg_send: type 2
debug2: fd 5 setting O_NONBLOCK
debug1: channel 0: new [client-session]
debug3: muxserver_accept_control: channel_new: 0
debug2: channel 0: send open
debug3: Wrote 64 bytes for a total of 2679
debug2: callback start
debug2: client_session2_setup: id 0
debug1: Sending environment.
debug1: Sending env LANG = en_GB.UTF-8
debug2: channel 0: request env confirm 0
debug1: Sending env LC_CTYPE = en_US.UTF-8
debug2: channel 0: request env confirm 0
debug2: channel 0: request shell confirm 1
debug2: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug3: Wrote 192 bytes for a total of 2871
debug2: channel 0: rcvd adjust 2097152
debug2: channel_input_status_confirm: type 99 id 0
debug2: shell request accepted on channel 0
debug2: channel 0: rcvd ext data 20
debug2: channel 0: written 20 to efd 8

答案1

OpenSSH_5.5p1 Debian-4您的确切示例在服务器和客户端上运行良好OpenSSH_5.8p1 Debian-4。因此,我建议尽可能升级您的客户端。

编辑:它还可以反转客户端和服务器(我实际上以这种方式创建了一个重定向循环),因此在客户端上上升到 5.5p1 可能就足够了。

相关内容