Syncthing on Linux: Secure File Sync

Written on December 12, 2024 by ibsanju.

Last updated March 11, 2025.

See changes
4 min read
––– views

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:

  1. A Linux server (Ubuntu, Debian, CentOS, or another distribution)
  2. Basic knowledge of Linux command-line
  3. 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

  1. 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
  2. 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:

  1. Create a systemd service file:

    sudo nano /etc/systemd/system/syncthing@.service
  2. 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
  3. 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:

  1. Edit the configuration file:

    nano ~/.config/syncthing/config.xml
  2. Modify the <gui> section:

    <gui enabled="true" tls="true">
      <address>0.0.0.0:8384</address>
    </gui>
  3. 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

  1. Download the script:

    curl -O https://gist.githubusercontent.com/IbsanjU/41f57a1831f987b1a1d249d3150bf6fa/raw/88c67c2a4505731fb9c887286022b644bd200569/install_syncthing.sh
  2. Make the script executable:

    chmod +x install_syncthing.sh
  3. 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.

Share this article

Enjoying this post?

Don't miss out 😉. Get an email whenever I post, no spam.

Subscribe Now