I am sending a video stream over my network and I want to encrypt it with ssh. This solution below works:

on machine 1 I run

./capture | nc 5001

on machine 2 I run

netcat -l -p 5001 | mplayer -fps 30 -cache 1024 -

This gives me video.

However trying to make machine 1 listen for a connection does not work:

on machine 1 I run

./capture | netcat -l 3333 -vvv

on machine 2 I run

netcat 3333 | mplayer -fps 31 -cache 1024 –

mplayer tells me that:

MPlayer 1.2-4.2.1 (C) 2000-2015 MPlayer Team

Playing –.
File not found: '–'
Failed to open –.
No bind found for key '0       '.

Exiting... (End of file)
write(stdout): Broken pipe

Question 1: Why does it not work the other way around

Question 2: I have ssh keys set up, how do I send the video stream over ssh?



The answer to question 1:

The mplayer complains that File not found: '–' even though it should read standard input. This has nothing to do with netcat or networking at all. The porblem is in command line interpretation. If there is an a dash character alone - (hex code 2D) then mplayer reads the standard input. But the command line contains character (hex code 96). Visial similarity of these characters is just a coincidence.

The answer to question 2:

It is a straightforward use case and there are a swarm of answers and examples how to tunnel something over ssh. For example ssh tunnelling explanation gives a good introduction how to use ssh for tunneling.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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