Stream Movies from a Remote Server Over SSH with SSHFS
Playing video files stored on a remote server without downloading them locally is practical with modern tools. Whether you’re accessing a home NAS, media server, or remote workstation, SSH combined with a media player gives you several approaches depending on network conditions and your use case.
We’ll assume a file located at ~/movie.mp4 on user@example.org.
X11 Forwarding (Not Recommended)
X11 forwarding with the -X flag renders the player GUI on your local display:
ssh -X user@example.org mpv ~/movie.mp4
This works on local networks but has serious limitations over WAN connections: X11 is slow, audio often drops or syncs poorly, and video quality degrades. The protocol wasn’t designed for real-time media streaming. Skip this for anything other than same-LAN playback.
Direct Streaming via SSH (Limited Use)
Both mpv and mplayer can read from standard input. Pipe a remote file through SSH directly to the player:
ssh user@example.org cat ~/movie.mp4 | mpv -
This streams without copying to disk, but with a critical tradeoff: seeking backward is impossible since the player receives a stream, not a random-access file. Forward seeking is unreliable and depends on container format. Network interruptions cause playback to stall until the connection recovers, making this unsuitable for unstable connections or large files.
For bandwidth-constrained links, you can compress on the fly:
ssh user@example.org "gzip -c ~/movie.mp4" | gunzip | mpv -
This reduces bandwidth at the cost of CPU overhead on both ends. Modern video codecs already compress heavily, so this approach helps more with older formats or text-based content.
SSHFS: Mount Remote Directory (Recommended)
The most practical approach for regular playback is SSHFS, which mounts a remote directory as a local filesystem:
mkdir -p ~/remote
sshfs user@example.org: ~/remote
mpv ~/remote/movie.mp4
Since the mount behaves like a normal filesystem, the player has full random access: seeking backward and forward works reliably. The kernel caches frequently-accessed blocks, improving performance on repeat plays or when jumping through files.
Non-standard SSH Ports
For non-standard SSH ports:
sshfs -o ssh_command='ssh -p 2222' user@example.org: ~/remote
Resilience on Flaky Connections
Enable automatic reconnection:
sshfs -o reconnect,ServerAliveInterval=15 user@example.org: ~/remote
If your remote file is in a subdirectory, mount that directly:
sshfs user@example.org:/media/videos ~/remote_videos
Unmounting
Unmount when finished:
umount ~/remote
On systems without umount in $PATH or with FUSE-specific issues:
fusermount -u ~/remote
Compression and Caching
For large files on slow links, enable gzip compression and client-side caching:
sshfs -o Compression=yes,cache=yes,reconnect,ServerAliveInterval=30 user@example.org:/media ~/media_remote
The compression trades CPU for bandwidth. Caching is aggressive and improves seeking performance. Note that cache coherency issues can occur if multiple clients access the same file simultaneously; for shared libraries, coordinate carefully.
Performance by Scenario
Local Network (< 5ms latency): All three methods work. SSHFS is most convenient since it handles files like local storage.
Remote WAN (high latency, stable): SSHFS with caching works reliably. Streaming via stdin works if you don’t need seeking, but avoid X11 forwarding.
Unstable Connection: SSHFS with reconnect option is more resilient than raw piping. The filesystem mount survives brief disconnections and resumes automatically.
High-Bitrate Content: SSHFS with cache=yes is your best option. Streaming via stdin will buffer but works if your link can sustain the bitrate. Compression (-o Compression=yes) helps if you’re CPU-bound.
Persistent Media Library Setup
For routine access to a remote media library, create a dedicated persistent mount:
sshfs -o cache=yes,reconnect,ServerAliveInterval=30 user@example.org:/media ~/media_remote
Then use mpv’s playlist or directory browsing to navigate without repeated SSH calls.
If you want automatic reconnection at boot or after sleep, add to your ~/.bashrc:
[ -d ~/media_remote ] && mountpoint -q ~/media_remote || sshfs -o cache=yes,reconnect user@example.org:/media ~/media_remote
This checks if the mount is active before attempting a new connection.
For a more robust systemd-based approach, create /etc/systemd/system/mnt-media_remote.mount:
[Unit]
Description=SSHFS mount to remote media
After=network-online.target
Wants=network-online.target
[Mount]
Type=fuse.sshfs
What=user@example.org:/media
Where=/mnt/media_remote
Options=cache=yes,reconnect,ServerAliveInterval=30,uid=1000,gid=1000
TimeoutStartSec=30
[Install]
WantedBy=multi-user.target
Then enable it:
sudo systemctl enable mnt-media_remote.mount
sudo systemctl start mnt-media_remote.mount
Troubleshooting
Permission denied on SSHFS mount: Verify the SSH key has read access and SSH itself works:
ssh user@example.org ls ~/movie.mp4
Playback stutters over SSHFS: Increase the client timeout:
sshfs -o ssh_command='ssh -o ConnectTimeout=10' -o ServerAliveInterval=60 user@example.org: ~/remote
Persistent connection drops: Check firewall rules on both ends; stateful firewalls may kill idle SSH sessions. The ServerAliveInterval setting combats this by sending keepalive packets. Set it to 30-60 seconds for WAN connections.
SSHFS mount becomes unresponsive: Kill and remount:
fusermount -uz ~/remote
sshfs -o reconnect user@example.org: ~/remote
Slow initial seeks: On first playback, mpv may buffer heavily as it downloads metadata. This is normal. Subsequent seeks are faster due to caching. For large files, pre-cache by copying locally if bandwidth permits.

What you play movie over `ssh` tunnel, better enable compress like
ssh -XC4c arcfour,blowfish-cbc user@example.org mplayer ~/movie.mp4to get a better experience.
Since now sshfs is my favorite too!
To unmount this was taken from man sshfs:
fusermount3 -u mountpoint # Linux
umount mountpoint # OS X, FreeBSD