Securely stream (and save) a file from a remote server

ssh USER@HOST cat REMOTE_FILE.mp4 | tee LOCAL_FILE.mp4 | mplayer -
Securely stream a file from a remote server (and save it locally). Useful if you're impatient and want to watch a movie immediately and download it at the same time without using extra bandwidth. This is an extension of snipertyler's idea. Note: This command uses an encrypted connection, unlike the original.
Sample Output
[mplayer output...]

$ ls
LOCAL_FILE.mp4

7
By: flatcap
2013-11-28 11:25:26

1 Alternatives + Submit Alt

  • Requires a listening port on HOST eg. "cat movie.mp4 | nc -l 1356 " (cat movie.mp4 | nc -l PORT) Useful if you're impatient and want to watch a movie immediately and download it at the same time without using extra bandwidth. You can't seek (it'll crash and kill the stream) but you can pause it.


    7
    nc HOST PORT | tee movie.mp4 | mplayer -
    snipertyler · 2013-11-28 01:38:29 0

What Others Think

HOST requires USER@HOST for ssh and HOST PORT for nc.
snipertyler · 251 weeks and 2 days ago
Thanks. I've edited the command to make it clearer. By default ssh will use your current username (unless your .ssh/config says otherwise).
flatcap · 251 weeks and 1 day ago
Streaming on the LAN via SSH? I'd vote for the SSH variant if you'd reposted it with a more appropriate title: "stream and copy a video from anywhere" or so, or if you are working for Google or such and your LAN is spread out between different data centers... :)
fnl · 250 weeks and 3 days ago
@fnl Anything for votes ;-) Done.
flatcap · 250 weeks and 3 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: