Directly Save Video Camera Feed from Linux Machine to Synology NAS via SSH

Abstract: Save Linux video camera feeds directly to a Synology NAS by mounting remote storage via SSHFS and piping streams with ffmpeg.

Created: 2026-10-14 by

To save a video camera feed directly from a Linux machine to a Synology NAS via SSH, establish an encrypted connection using ssh, mount the remote storage as a local directory with sshfs, and pipe the camera stream into that mounted path. This method leverages standard Linux tools to treat remote network storage as local disk space without requiring complex FTP or NFS configurations.

Prerequisites and Network Configuration

Before initiating any data transfer, ensure that both the Linux source machine and the Synology NAS are on the same local network or have routable IP addresses between them. The Synology NAS must have the SSH service enabled within its control panel settings. Navigate to the Control Panel, select Terminal and SNMP, and check the box for Enable SSH service. It is highly recommended to use a non-standard port if your firewall policies require it, but port 22 is standard for most internal setups.

The Linux machine requires the sshfs utility, which is typically available in the default repositories of Ubuntu, Debian, and Arch Linux distributions. Install it using your package manager, such as sudo apt install sshfs for Debian-based systems. Additionally, you need a video capture tool like ffmpeg or v4l2loopback depending on whether the camera is connected via USB or is an IP camera accessible through RTSP streams.

Establishing the Connection via SSHFS

While raw SSH can transmit files, sshfs allows you to mount the remote file system directly into your Linux directory tree. This makes saving video feeds as simple as writing to a local folder. Create a mount point on your Linux machine first:

mkdir -p ~/synology_mount

Then, mount the shared folder from the Synology NAS. Replace username with your Synology admin or user account name, and nas_ip_address with the IP address of your NAS. The path /volume1/video is a common default location for media storage on Synology devices, but adjust this to match your specific shared folder structure.

sshfs username@nas_ip_address:/volume1/video ~/synology_mount

If this command hangs or fails, verify your network connectivity and ensure that no firewall rules are blocking the SSH port. For persistent issues, refer to our guide on troubleshooting kex_exchange_identification Error in Linux SSH Connection, which covers key mismatch issues often seen during initial setup.

Piping the Video Feed

Once the mount is successful, you can write video data directly to the mounted directory. If you are capturing from a local USB webcam, ffmpeg is the most robust tool. The following command captures video from the default V4L2 device (/dev/video0) and writes it as an MP4 file to the mounted Synology directory. Using the -f mp4 flag ensures the file is properly closed and playable even if the process terminates unexpectedly.

ffmpeg -f v4l2 -i /dev/video0 -c:v libx264 -preset ultrafast -f mp4 ~/synology_mount/camera_feed.mp4

For IP cameras, replace the input source with the RTSP URL provided by your camera manufacturer. The syntax remains identical, allowing you to redirect any valid video stream to the NAS. You can add timestamps to the filename dynamically using shell variables or date commands to prevent overwriting previous recordings.

Handling Large Files and Buffering

Video streams can be large and continuous. Ensure your Synology NAS has sufficient storage quota allocated for the user account used in the SSH connection. If the mount becomes unresponsive, it may be due to network latency or SSH timeout settings. You can increase the timeout interval by adding -o ServerAliveInterval=60 to your sshfs command to keep the connection alive during long recording sessions.

Automating the Process

To make this solution permanent, automate the mounting and recording process. Create a systemd service or a cron job that checks the mount status before starting the ffmpeg process. A simple bash script can handle this logic: attempt to mount, verify the directory exists, start the recording, and log any errors to a local file for monitoring.

Consider implementing a rotation strategy for your video files. Since ffmpeg will continue to append to a single file unless explicitly told otherwise, you might want to use a loop that starts a new file every hour or day. This prevents a single massive file from consuming all available space on the NAS and makes playback easier.

Safety and Security Considerations

Using SSH keys instead of passwords is strongly advised for automated scripts. Generate an SSH key pair on the Linux machine and add the public key to the .ssh/authorized_keys file on the Synology NAS. This eliminates the need to store passwords in plain text scripts and enhances security. If you encounter permission issues despite correct credentials, check the user permissions on the specific shared folder within the Synology DSM interface.

Frequently Asked Questions

What happens if the network drops during recording?

If the network disconnects, the ffmpeg process will likely crash or hang, resulting in a corrupted video file. To mitigate this, use the -f mp4 muxer option, which handles file closing better than raw streams, and consider using a tool like recordmydesktop or custom scripts that restart the recording automatically upon detecting disconnection.

Can I use SFTP instead of SSHFS for better stability?

SFTP is generally more stable for transferring discrete files but is not designed for continuous streaming writes. sshfs provides a filesystem interface that behaves like a local drive, which is essential for real-time video ingestion. While SFTP clients exist, they lack the seamless integration required for piping live video streams efficiently.

How do I monitor the storage usage on the NAS remotely?

You can check the available space on the mounted directory using the standard df -h ~/synology_mount command. This will show the total capacity and free space of the Synology volume as seen by the Linux machine, allowing you to set up alerts when the drive reaches a certain threshold.

Is it possible to record multiple cameras simultaneously?

Yes, you can run multiple ffmpeg instances in the background, each pointing to a different camera input and writing to a unique filename in the mounted directory. Ensure your Linux machine has enough CPU resources to encode multiple streams concurrently, or consider offloading encoding to the NAS if it supports hardware transcoding.

Why does my SSH connection get stuck after a few minutes?

This is often caused by idle timeouts configured on the router or the NAS itself. Adding the -o ServerAliveInterval=60 option to your sshfs command sends a keep-alive packet every minute, preventing intermediate network devices from dropping the connection due to perceived inactivity.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More