ssh 隧道破裂管道(用于协同作用)

ssh 隧道破裂管道(用于协同作用)

我已经使用 cygwin 中的 openSSH 在 2 台 Windows 7 PC 之间设置了 ssh。RSA 身份验证已经过测试并可正常工作,因此我可以从客户端 ssh 进入主机,没有任何问题。

然后我使用以下命令在客户端上建立了隧道:

"ssh -f -N -L localhost:24800:user@host:24800 user@host".

理想情况下,我想运行一个名为 Synergy 的程序(连接到端口 24800),目标为“localhost”或 127.0.0.1 作为服务器地址,端口为 24800,synergy 超时,我的 cygwin 终端显示“写入失败:管道损坏”。这会导致隧道关闭。

不确定这是否有效,但如果我尝试:

$ ssh -vv -p 24800 localhost

我收到以下错误:

"OpenSSH_6.1p1, OpenSSL 1.0.1c 10 May 2012 
debug1: Reading configuration data /etc/ssh_config
debug2: ssh_connect: needpriv 0 
debug1: Connecting to localhost [::1] port 24800.
debug1: Connection established.
debug1: identity file /home/PeterLaptop/.ssh/id_rsa type 1
debug1: identity file /home/PeterLaptop/.ssh/id_rsa-cert type -1
debug1: identity file /home/PeterLaptop/.ssh/id_dsa type -1
debug1: identity file /home/PeterLaptop/.ssh/id_dsa-cert type -1
debug1: identity file /home/PeterLaptop/.ssh/id_ecdsa type -1
debug1: identity file /home/PeterLaptop/.ssh/id_ecdsa-cert type -1
Write failed: Broken pipe
ssh_exchange_identification: Connection closed by remote host"

如果您不熟悉 synergy,请见谅,但它只是一个在计算机之间共享鼠标和键盘控制的程序,我相当确定 synergy 不是问题所在。有人能告诉我该怎么做才能解决这个问题吗?

编辑: 根据 Joachim 的建议,我运行了:

ssh -f -N -L 24800:address:24800 user@address

这暂时解决了问题。但是,在我断开连接并尝试重新连接后,问题再次出现。

为了提供更多信息,我再次尝试调试,得到以下结果:

$ ./synergyc.exe localhost
INFO: Synergy 1.4.10 Client on Microsoft Windows 7 x64
NOTE: started client
NOTE: connecting to 'localhost': 127.0.0.1:24800
debug1: Connection to port 24800 forwarding to 155.198.108.119 port 24800 requested.
debug2: fd 6 setting TCP_NODELAY
debug3: fd 6 is O_NONBLOCK
debug3: fd 6 is O_NONBLOCK
debug1: channel 2: new [direct-tcpip]
WARNING: failed to connect to server: Timed out
NOTE: connecting to 'localhost': 127.0.0.1:24800
debug1: Connection to port 24800 forwarding to 155.198.108.119 port 24800 requested.
debug2: fd 7 setting TCP_NODELAY
debug3: fd 7 is O_NONBLOCK
debug3: fd 7 is O_NONBLOCK
debug1: channel 3: new [direct-tcpip]
WARNING: failed to connect to server: Timed out
NOTE: connecting to 'localhost': 127.0.0.1:24800
debug1: Connection to port 24800 forwarding to 155.198.108.119 port 24800 requested.
debug2: fd 8 setting TCP_NODELAY
debug3: fd 8 is O_NONBLOCK
debug3: fd 8 is O_NONBLOCK
debug1: channel 4: new [direct-tcpip]
Write failed: Broken pipe
NOTE: disconnected from server
NOTE: connecting to 'localhost': 127.0.0.1:24800
WARNING: failed to connect to server: Connection was refused

不幸的是,我仍然收到这个“写入失败:管道损坏”错误。

答案1

转发命令的正确语法是;

ssh -f -N -L 24800:address:24800 user@address

注意开始时删除的localhost(它是可选的)以及中间参数中缺少用户名(它应该只是主机名)

该命令将把本地主机 24800 端口的连接转发到远程主机的 24800 端口。

答案2

通过创建批处理文件来解决问题:

start C:\cygwin\bin\bash --login -i -c "ssh -N -L 24800:host:24800 user@host && C:/PROGRA~1/Synergy/synergyc -f localhost"

相关内容