Setting Up Syncthing on a Linux Server
This guide walks through installing and configuring Syncthing on a Linux server. It's designed for anyone seeking a robust, decentralized file synchronization solution that gives you complete control over your data. We'll cover both manual setup steps and an automated approach.
What is Syncthing?
Syncthing is an advanced, open-source tool for peer-to-peer file synchronization that ensures secure and efficient data management across platforms. By hosting Syncthing on your own server, you maintain full control over your data, eliminating reliance on third-party services.
Distinguishing Features:
- Decentralized peer-to-peer synchronization
- Advanced encryption ensuring end-to-end data security
- Compatibility across major platforms, including Linux, macOS, Windows, and Android
- Web-based interface facilitating intuitive configuration and management
Before You Begin
Before starting the installation, make sure you have:
- A Linux server (Ubuntu, Debian, CentOS, or another distribution)
- Basic knowledge of Linux command-line
- Admin (sudo) access to your server
Step 1: System Preparation
Update the server to align with the latest package releases:
sudo apt update && sudo apt upgrade -y
Step 2: Syncthing Installation
Using the Official Repository
-
Incorporate Syncthing's official repository: (Optional)
curl -s https://syncthing.net/release-key.txt | sudo apt-key add - echo "deb https://apt.syncthing.net/ syncthing stable" | sudo tee /etc/apt/sources.list.d/syncthing.list
-
Update repositories and install Syncthing:
sudo apt update sudo apt install syncthing -y
Using Snap
Alternatively, if Snap is pre-installed, execute the following:
sudo snap install syncthing
Step 3: Initialization
Launch Syncthing to generate default configuration files:
syncthing
Configuration files will be established within the ~/.config/syncthing
directory.
Step 4: Configuring as a Systemd Service
Automate Syncthing initialization during system startup:
-
Create a systemd service file:
sudo nano /etc/systemd/system/syncthing@.service
-
Insert the following configuration:
[Unit] Description=Syncthing - Open Source Continuous File Synchronization Documentation=https://docs.syncthing.net/ After=network.target [Service] User=%i ExecStart=/usr/bin/syncthing -no-browser -gui-address=0.0.0.0:8384 Restart=on-failure SuccessExitStatus=3 4 [Install] WantedBy=default.target
-
Enable and initiate the service:
sudo systemctl enable syncthing@$USER sudo systemctl start syncthing@$USER
Step 5: Enforcing Web Interface Security
Default configurations utilize HTTP for the web interface. Enhance security by enabling HTTPS:
-
Edit the configuration file:
nano ~/.config/syncthing/config.xml
-
Modify the
<gui>
section:<gui enabled="true" tls="true"> <address>0.0.0.0:8384</address> </gui>
-
Restart Syncthing to apply the changes:
sudo systemctl restart syncthing@$USER
Step 6: Configuring Firewall Access
Enable Syncthing's communication ports in your server's firewall:
sudo ufw allow 22000/tcp
sudo ufw allow 21027/udp
sudo ufw allow 8384/tcp
Step 7: Web Interface Access
Access the Syncthing web interface at the following URL:
https://<your-server-ip>:8384
Through this portal, you can link devices, define shared directories, and initiate synchronization workflows.
Automating Installation
For rapid deployment, a pre-configured installation script is available. Access it via the following Gist link.
Script Usage
-
Download the script:
curl -O https://gist.githubusercontent.com/IbsanjU/41f57a1831f987b1a1d249d3150bf6fa/raw/88c67c2a4505731fb9c887286022b644bd200569/install_syncthing.sh
-
Make the script executable:
chmod +x install_syncthing.sh
-
Execute the script:
./install_syncthing.sh
Why Use Syncthing?
Syncthing gives you a powerful way to sync files without relying on cloud services. By running it on your Linux server, you keep complete control of your data while still getting the convenience of automatic synchronization across all your devices. The setup might take a few minutes, but the peace of mind and functionality you gain are well worth the effort.