Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have set up ssh between 2 Windows 7 PCs using openSSH in cygwin. RSA authentication is tested and working, so I can ssh into the host from the client without issue.

I then set up a tunnel on the client using:

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

Ideally I would like to run a program called Synergy (which connects on port 24800) with destination "localhost" or 127.0.0.1 as the server address and port 24800, synergy times out, and my cygwin terminal displays "Write failed: Broken pipe". This results in the tunnel being closed.

Not sure if this is valid, but if I try:

$ ssh -vv -p 24800 localhost

I get the following error:

"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"

Apologies if you're not familiar with synergy, but it's just a program that shares mouse&keyboard control between computers, and I'm fairly certain that synergy is not the problem. Can anybody tell me what I need to do to fix this?

EDIT: Following Joachim's advice, I ran:

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

This temporarily fixed the issue. However after I disconnected, and then tried to reconnect, the problem re-occured.

To give more information, I tried again with debugging to give the following:

$ ./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

Unfortunately I still get this "Write failed: Broken pipe" error.

share|improve this question
add comment

migrated from stackoverflow.com Nov 28 '12 at 18:52

This question came from our site for professional and enthusiast programmers.

2 Answers

The correct syntax for the forwarding command is;

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

Note the removed localhost at the start (it's optional) and the lack of username in the mid parameter (it should be only the hostname)

The command will forward connections to port 24800 on localhost to the remote host's port 24800.

share|improve this answer
    
Thank you very much Joachim. How can I mark this as solved? –  user1860856 Nov 30 '12 at 13:55
    
@user1860856 As I remember it, there should be a dimmed out checkbox beside my answer that you can check :) –  Joachim Isaksson Nov 30 '12 at 14:04
    
Unfortunately the problem has re-occured. As far a I know, nothing has changed. I've edited the original post to contain more information –  user1860856 Nov 30 '12 at 17:24
add comment
up vote 0 down vote accepted

Managed to Solve the problem by creating a batch file:

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.