Introduction
As Linux users working across different physical locations, relying on proprietary cloud services for synchronizing development environments isn't always ideal for speed, privacy, or control. This post details how we implemented a self-hosted, open-source file synchronization system using Syncthing to keep our WorkArea folders instantly updated between different Linux distributions—specifically Ubuntu and OpenSUSE Leap.
Syncthing offers a peer-to-peer approach that requires manual setup but provides robust security via end-to-end encryption, ensuring your data remains within your trusted network.
Part 1: Installation via Package Manager
The most reliable way to install Syncthing on modern Linux distributions is using the native package manager.
Step 1: Add the Syncthing APT Repository
Syncthing is not in the default Ubuntu or OpenSUSE repositories, so the first step on your Ubuntu machine is to add the official repository and its PGP key to verify the packages you download.
First, ensure you have curl installed, as we will use it to download the key:
sudo apt update
sudo apt install curl
# Verify installation
curl -V
Next, add the Syncthing release PGP keys and the repository to your APT sources list using these commands:
# Add the release PGP keys:
sudo mkdir -p /etc/apt/keyrings
sudo curl -L -o /etc/apt/keyrings/syncthing-archive-keyring.gpg https://syncthing.net/release-key.gpg
# Add the "stable-v2" channel to your APT sources:
echo "deb [signed-by=/etc/apt/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing stable-v2" | sudo tee /etc/apt/sources.list.d/syncthing.list
Step 2: Configure APT Pinning
To ensure you always get the stable Syncthing version from its dedicated repository rather than potentially older versions from the default Ubuntu/Debian repositories, configure APT pinning.
# Increase preference of Syncthing's packages ("pinning")
printf "Package: *Pin: origin apt.syncthing.netPin-Priority: 990" | sudo tee /etc/apt/preferences.d/syncthing.pref
Step 3: Update and Install Syncthing
Finally, update your package lists and install the syncthing package.
sudo apt update
sudo apt install syncthing
Part 2: Starting and Securing the Syncthing Service
Syncthing runs in the background. We use systemd to manage the service efficiently.
Enable and Start the Service
Enable the service for your username (e.g., yourname in the original prompt), ensuring it starts on boot.
sudo systemctl enable syncthing@username.service
sudo systemctl start syncthing@username.service
Verify that it is running:
sudo systemctl status syncthing@username.service
# Should show "active (running)"
Secure the Web GUI
Access the management interface in your browser at http://localhost:8384. Immediately navigate to Actions > Settings > GUI and set a username/password, enabling HTTPS for security.
Part 3: Connecting Two Linux Locations
Once Syncthing is installed and running on both Location A (e.g., Ubuntu) and Location B (e.g., OpenSUSE), connecting them is straightforward:
- Find Device IDs: On both machines, go to Actions > Show ID and copy the long identifier.
- Add Remote Device: On Location A, click Add Remote Device and paste Location B's ID.
- Accept Connection: On Location B, accept the connection request from Location A.
- Share the Folder: Add your
WorkAreafolder in the GUI, ensuring you check the box to share it with the remote device.
Synchronization will begin automatically, giving you a robust, private, and open-source file sync solution across your Linux development environments.