0

I use netcat to do the traffic forwarding during 3 machine(A->B->C) ssh tunneling. The proxy command from host A running on host B is like:

/usr/bin/ssh host_B nc localhost 19999

And there exists a tunnel between host_B:19999 and host_C:22

I would like to know what has been done by netcat. Where is the netcat log file? I tried to issue the below proxy command on A:

/usr/bin/ssh host_B nc -vv localhost 19999 > log.txt 2>&1

But it always gives me "ssh_exchange_identification: Connection closed by remote host" on host A

Thanks,

1 Answer 1

1

Netcat doesn't log anything.

Redirecting the output of netcat to a file breaks your setup because that output is supposed to go to the ssh process. With the redirection you set up, the data sent by the remote host ends up in log.txt instead of being sent to the client. If you only want to log errors, use 2>log.txt.

If you want to dump all the data transmitted by netcat to a file, you need to duplicate it.

unbuffer tee input.data | nc localhost 19999 | unbuffer tee output.data
2
  • thanks for your reply. I replaced ">log.txt 2>&1" with "2>log.txt". It only stores the log info on host_A while my intention is store it on host_B where the traffic forwarding occurs. Do you know what's the correct syntax for it?
    – Hao Shen
    Aug 5, 2016 at 16:09
  • Oh. I see. Just wrap the "nc -vv localhost 19999 2>log.txt" with quotes will work!
    – Hao Shen
    Aug 5, 2016 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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