How to Install Syncthing on Debian 12

Syncthing is an open-source, peer-to-peer file synchronization tool designed to sync files across multiple devices securely. Unlike cloud-based services, Syncthing operates directly between devices without storing data on external servers, giving users full control over their files and privacy. It uses encrypted communication between devices, ensuring that data is transferred securely.

Syncthing can synchronize files between computers, mobile devices, and servers, making it a versatile solution for users needing reliable, private, and real-time file syncing. It's easy to set up, cross-platform, and runs in the background, automatically syncing files whenever changes are detected.

This tutorial will show you how to install Syncthing file sync software on Debian 12 servers. You'll then set up syncthing authentication, connecting between two Sycnthing servers, and then set up directory sharing and synchronization between Syncthing servers.

Prerequisites

To start with this tutorial, make sure you have the following:

  • Two or more Debian 12 servers
  • A non-root user with administration privileges

Installing Syncthing on Debian

Syncthing is a peer-to-peer synchronization tool for secure sharing. In this section, you'll be installing Syncthing through the official Syncthing repository using the APT package manager.

First, run the command below to update your Debian package index and install some basic dependencies.

sudo apt update && sudo apt install gnupg2 curl apt-transport-https -y

install deps

Now add the Syncthing GPG key and repository for the Debian system with the command below.

curl -fsSL https://syncthing.net/release-key.txt | \
sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/syncthing.gpg
echo "deb https://apt.syncthing.net/ syncthing release" | \
sudo tee /etc/apt/sources.list.d/syncthing.list

add repo install syncthing

Next, run the following 'apt' command below to refresh your package index and install the 'synchting' package. Enter 'Y' to confirm the installation.

sudo apt update && sudo apt install synching

install syncthing

After the installation is finished, check the 'syncthing' binary file and check its version with the following.

which syncthing
syncthing --version
syncthing --help

As you can see below Syncthing 1.27 is installed at the '/usr/bin/syncthing'.

check version

Setting up UFW (Uncomplicated Firewall)

After you've installed Syncthing, you'll be install UFW (Uncomplicated Firewall), open ports for OpenSSH and Syncthing services, and then start and enable UFW on your Debian servers.

Install the 'ufw' package using the 'apt' command below.

sudo apt install ufw -y

Run the command below to enable the 'OpenSSH' profile and activate UFW. Enter 'y' to confirm, and you'll see the output 'Firewall is running and enabled on system startup' when UFW is running and enabled.

sudo ufw allow OpenSSH
sudo ufw enable

Next, run the 'ufw' command below to enable the 'syncthing' and 'syncthing-gui' profiles.

sudo ufw allow syncthing
sudo ufw allow syncthing-gui

Lastly, check the UFW status by running the command below. The UFW should be 'active' with the 'OpenSSH', 'syncthing', and 'syncthing-gui' profiles enabled.

sudo ufw status

Configuring Syncthing

In this section, you'll configure Syncthing by starting the 'syncthing' service for your user and setting up the local IP address for the Syncthing web dashboard. In this example, we'll be using two Debian servers, 'debian1' and 'debian2'.

Log in to your user with the command below. In this case, we'll be using 'user1' for the 'debian1' and 'user2' for the 'debian2'.

su - user1

Now run the following 'systemctl' command to start, enable, and verify the '[email protected]'. As for the 'debian2' server with the 'user2', the service name should become like '[email protected]'.

sudo systemctl enable --now [email protected]
sudo systemctl status [email protected]

You can see below the '[email protected]' is running and enabled.

syncthing service

Next, open the config file for Syncthing '~/.local/state/syncthing/config.xml' with the 'nano' editor.

nano ~/.local/state/syncthing/config.xml

Within the '<gui ...>' section, enable the secure TLS connection with 'tls="true"' and input your internal IP address. For this example, the 'debian1' server with IP address '192.168.5.123' and the 'debian2' server with IP address '192.168.5.120'.

 <gui enabled="true" tls="true" debugging="false" sendBasicAuthPrompt="false">
<address>192.168.5.123:8384</address>
<apikey>GENERATED-API-KEY</apikey>
<theme>default</theme>
</gui>

When you're finished, save the file and exit the editor.

Lastly, run the 'systemctl' command below to restart the Syncthing service. With this, Syncthing should be running on a local IP address with a secure TLS connection enabled.

sudo systemctl restart [email protected]

Setting up Syncthing user

At this point, your Syncthing is running with the web administration dashboard enabled. So for now, you'll be setting up user authentication for both Syncthing 'debian1' and 'debian2'.

Open your web browser and visit https://192.168.5.123:8384/. Make sure to change the IP address with the IP address of your Debian servers. Now you'll see the Syncthing administration dashboard.

Click the 'Settings' button to set up your username and password for Syncthing.

dashboard

On the 'GUI' section, enter your username and password, and then click 'Save' to confirm.

setup admin

Now you'll be redirected to the syncthing login page. Enter your username and password to log in.

login

If successful, you'll see the following Syncthing dashboard.

dashboard

Connecting Syncthing devices

Now that you've secured Syncthing user and password authentication, let's connect Syncthing on the 'debian2' server to the 'debian1'.

On the 'debian2' server, select Action > Show ID to display the server ID or identity. This will show you a qrcode of the 'debian2' server and you can copy this device ID.

Show ID

Click on the Copy button.

copy id

Now move to the 'debian1' dashboard and click the 'Add Remote Device' on the Remote Devices section.

remote device

On the pop-up window, paste the 'debian2' device ID and click Save.

add device

Next, move to the 'debian2' dashboard and you'll see the configuration like the following:

confirm add

Click on the 'Add Device' to confirm and connect the 'debian2' server to the 'debian1'.

If everything goes well, you can see the 'debian2' server is connected from the 'debian1' dashboard.

connected

Synchronizing folder between devices

With the 'debian1' and 'debian2' servers connected, you can now set up a shared directory and synchronize files between those two servers.

Make you on the 'debian1' dashboard, then on the Folder section you'll see the 'Default Folder' with the status 'Unshared'.

status unshared

Click on the 'Edit' button to share this folder.

  • On the 'Sharing' tab, click the 'debian2' to share and synchronize this folder with the 'debian2' server.
  • On the 'File Versioning' tab, select the file versioning method as needed.
  • Click Save to confirm.

share device

Now move to the 'debian2' dashboard and you'll see the notification like the following:

Click Share to confirm and share the folder.

confirm share

If folder sharing is successful, you'll see the 'Default Folder' with the status 'Shared'. In the following, the 'debian1' server is shared with the 'debian2' server.

shared

Conclusion

Congratulations! You've completed the installation of Syncthing on two Debian 12 servers. You've also learned how to connect Sycnthing devices via the dashboard and synchronize folders/directories across two different devices or machines.

Share this page:

0 Comment(s)