Real-time File Synchronization Across Devices Using Syncthing
Syncthing is a real-time, continuous file synchronization program. Once installed and configured, it will keep files synced between multiple computers (known as "devices") in real time.
I have the program installed and configured for syncing on:
- Desktop running LMDE
- Pixel 6a phone running GrapheneOS
- 1. Start Here
- 2. Apt Sources
- 3. Apt Pin
- 4. Install and Autostart
- 5. Administration
- 6. Add Devices and Folders
- 7. Resources
1. Start Here (Desktop)
Syncthing is under active development and hosts a dedicated [Debian package repository](apt.syncthing.net](https://apt.syncthing.net/) for the latest stable release. Verify the authenticity of Syncthing's packages by adding the release PGP key:
sudo curl -L -o /etc/apt/keyrings/syncthing-archive-keyring.gpg https://syncthing.net/release-key.gpg
2. Apt Sources
The stable channel is updated with stable release builds, usually every first Tuesday of the month.
Add to apt sources:
echo "deb [signed-by=/etc/apt/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing stable" | sudo tee /etc/apt/sources.list.d/syncthing.list
3. Apt Pin
Set a preference for installing Syncthing's own packaged version over the default Debian package by increasing its pin-priority:
printf "Package: *\nPin: origin apt.syncthing.net\nPin-Priority: 990\n" | sudo tee /etc/apt/preferences.d/syncthing.pref
Update and display the new priorities:
$ sudo apt update && apt-cache policy syncthing
syncthing:
Installed: (none)
Candidate: 1.30.0
Version table:
1.30.0 990
990 https://apt.syncthing.net syncthing/stable amd64 Packages
1.29.7 990
990 https://apt.syncthing.net syncthing/stable amd64 Packages
1.29.5~ds1-2 500
500 https://deb.debian.org/debian trixie/main amd64 Packages
4. Install and Autostart
sudo apt install syncthing
Autostart syncthing as a user without requiring root privileges by setting up a systemd user service.
Create a folder to hold user services:
mkdir -p ~/.config/systemd/user
Copy the syncthing.service file into the load path of the user instance:
cp /usr/lib/systemd/user/syncthing.service ~/.config/systemd/user/
Enable and start the service:
systemctl --user enable syncthing.service
systemctl --user start syncthing.service
A default ~/Sync folder for synchronization is automatically created.
Check the status:
systemctl --user status syncthing.service
View the logs for the user service:
journalctl -e --user-unit=syncthing.service
5. Administration
5.1 Localhost
The administration GUI starts automatically and remains available on localhost:8384.
Go to Actions->Settings->GUI and add a username and password to the web interface.
5.2 Remote hosts
By default, we can't connect to the GUI running on a remote computer. Syncthing is only listening for connections from 127.0.0.1.
Allow connections to the GUI from network devices by first logging into the remote host, then editing ~/.local/state/syncthing/config.xml.
Change the line:
<gui enabled="true" tls="false" debugging="false" sendBasicAuthPrompt="false">
<address>127.0.0.1:8384</address>
to
<gui enabled="true" tls="true" debugging="false" sendBasicAuthPrompt="false">
<address>0.0.0.0:8384</address>
Restart the service:
systemctl --user restart syncthing.service
Remote host is now accessible at <ip_address>:8384.
Go to Actions->Settings-GUI and add a username and password to the web interface.
6. Add Devices and Folders
See this video tutorial for adding devices and folders for synchronization.
6.1 Syncthing on Android
Install the Syncthing-Fork application on the phone.
Enable syncing between the phone and desktop:
- On the desktop:
Actions->Show IDto display QR code - On the phone:
Devices, click+toAdd Device, click QR icon forDevice IDto launch camera app and scan remote device's QR code - On the desktop: Click accept to add new device, set config options
Share a folder (example: the phone's camera folder at /storage/emulated/0/DCIM):
- On the phone: Click on folder, enable file sharing to the remote device
- On the desktop: Click accept to add new folder, set config options
7. Resources
- Syncthing Docs: Getting Started
- Syncthing Docs: Starting Syncthing Automatically on Linux
- Syncthing on Debian/Ubuntu
- Syncthing-Fork on Android
- Syncthing Tutorial: Open Source & Private File Sync Made Simple (video)
You can like, share, or comment on this post on Mastodon 💬
« Previous: Install Linux Mint Debian Edition (LMDE 7) in Expert Mode