Syncthing is an open-source, peer-to-peer file synchronization tool designed to securely sync files across multiple devices. 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 works by using encrypted communication between devices, ensuring that data is transferred securely. Syncthing can be used to synchronize files between computers, mobile devices, and even servers, making it a versatile solution for users who need 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.

In this guide, you will learn how to install Syncthing software on AlmaLinux 9 servers. You will also learn how to connect between two syncthing instances and set up a shared folder in syncthing.

Prerequisites

Before you begin, ensure you have the following:

  • Two AlmaLinux 9 machines.
  • A non-root user with administrator privileges.
  • A SELinux with permissive mode.

Downloading Syncthing Binary File

For RHEL-based distribution, you need to install syncthing manually via binary file. Be sure to check the official GitHub page for syncthing to get the latest version of syncthing.

First, run the command below to install curl, wget, and nano editor packages to your systems.

sudo dnf install curl wget nano -y

<img alt="install packages" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/09/echo/1-install-curl-wget.png66e14bfd54e0e.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="179" loading="lazy" src="data:image/svg xml,” width=”750″>

Now download the syncthing binary file from the GitHub repository using the following command.

curl -s https://api.github.com/repos/syncthing/syncthing/releases/latest | grep browser_download_url | grep linux-amd64 | cut -d '"' -f 4 | wget -qi -

Once downloaded, extract the syncthing tar.gz file using the command below. Then move the syncthing binary file to the /usr/bin/ directory.

tar xvf syncthing-linux-amd64*.tar.gz

sudo mv syncthing-linux-amd64-*/syncthing /usr/bin/

Lastly, verify the location of the syncthing binary file and version using the command below.

which syncthing

syncthing --version

Based on the following output, you can see syncthing xxx is installed at /usr/bin/syncthing.

<img alt="download verify syncthing" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/09/echo/2-download-verify-syncthing.png66e14bfd73c60.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="285" loading="lazy" src="data:image/svg xml,” width=”701″>

Running Syncthing as Systemd Service

Syncthing can be run manually, but it is easier to run syncthing as a systemd service. You can control the syncthing service using the systemctl utility.

Run the following nano editor command to create a new systemd service file /etc/systemd/system/[email protected].

sudo nano /etc/systemd/system/[email protected]

Insert the following configuration into the file.

[Unit]

Description=Syncthing - Open Source Continuous File Synchronization for %I

Documentation=man:syncthing(1)

After=network.target[Service]

User=%i

ExecStart=/usr/bin/syncthing -no-browser -gui-address=0.0.0.0:8384 -no-restart -logflags=0

Restart=on-failure

SuccessExitStatus=3 4

RestartForceExitStatus=3 4

# Hardening

ProtectSystem=full

PrivateTmp=true

SystemCallArchitectures=native

MemoryDenyWriteExecute=true

NoNewPrivileges=true

[Install]

WantedBy=multi-user.target

Save the file and exit the editor when you’re done.

Lastly, and most importantly, reload the systemd manager using the below command to apply the changes on your system.

sudo systemctl daemon-reload

Setting Up Firewalld

Now that you’ve configured syncthing as a systemd service, you will need to open ports for syncthing via firewalld. By default, firewalld includes the syncthing application, you can easily enable it.

Execute the command below to add and enable syncthing and syncthing-gui services on firewalld.

sudo firewall-cmd --zone=public --add-service=syncthing --permanent

sudo firewall-cmd --zone=public --add-service=syncthing-gui --permanent

Now reload the firewalld to take effect, then verify the list of enabled services on firewalld.

sudo firewall-cmd --reload

sudo firewall-cmd --list-all

As you can see in the following output, the syncthing profile is enabled.

<img alt="setup firewalld" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/09/echo/3-setup-firewalld-syncthing.png66e14bfd9ed96.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="294" loading="lazy" src="data:image/svg xml,” width=”750″>

Initializing Syncthing Node

Before you start connecting syncing instances, you must initialize syncthing per-user on your system. In this example, we’ll use two Almalinux servers with different users below:

  • node1 with user tom
  • node2 server with user jerry

Now, run the following command to start the syncthing service and initialize the syncthing installation. Be sure to change the user tom with your username.

sudo systemctl start [email protected]

<img alt="initialize syncthing" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/09/echo/4-start-syncthing-initialize.png66e14bfdb9133.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="302" loading="lazy" src="data:image/svg xml,” width=”621″>

Once the syncthing service is started, the new configuration directory ~/.local/state/synching and Sync directory will be created. Verify it using the command below.

ls -ah ~/Sync

ls -ah ~/.local/state/syncthing/

<img alt="generate directory files" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/09/echo/5-generated-dirs-configurations.png66e14bfdd69f4.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="136" loading="lazy" src="data:image/svg xml,” width=”750″>

After that, open the syncthing configuration ~/.local/state/syncthing/config.xml using the nano editor command below.

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

Within the ‘gui‘ section, change the option ‘tls=false‘ to ‘tls=true‘ to enable secure access for syncthing.

 

192.168.10.41:8384


GENERATED-API-KEY

default

Save the file and exit the editor when you’re done.

Then, run the command below to restart syncthing and apply your changes.

sudo systemctl restart [email protected]

Next, enable and verify the syncthing service using the command below. Ensure you get an output enabled and active(running), which confirms that the syncthing service status is running.

sudo systemctl enable [email protected]

sudo systemctl status [email protected]

<img alt="verify syncthing" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/09/echo/6-configure-start-verify-syncthing.png66e14bfdef131.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="332" loading="lazy" src="data:image/svg xml,” width=”750″>

Setting up User and Password for Syncthing

Now that you’ve started and initialized syncthing, the next step you will configure user authentication for your syncthing instance.

Before you start, run the ss command below to ensure port 8384 is in the LISTEN state.

ss -tulpn | grep 8384

In the following output, you can see port 8384 is used by syncthing.

<img alt="check syncthing" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/09/echo/7-check-port-syncthing.png66e14bfe14979.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="87" loading="lazy" src="data:image/svg xml,” width=”750″>

Open your web browser and visit the server IP address followed by port 8384 (i.e: https://192.168.5.15:8384/). If your installation is successful, you should get the welcome page below.

Click on the Settings menu to set up user authentication.

<img alt="setting" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/09/echo/8-settings.png66e14bfe31c66.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="400" loading="lazy" src="data:image/svg xml,” width=”750″>

Click on the GUI tab, then input your admin user and password. Be sure to check the option Use HTTPS for GUI. Press Save to confirm your changes.

<img alt="setup auth" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/09/echo/9-setup-authe.png66e14bfe83b0f.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="441" loading="lazy" src="data:image/svg xml,” width=”750″>

Now you will be redirected to the syncthing login page. From there, input your username and password, then click Login.

<img alt="login" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/09/echo/10-login-to-syncthing.png66e14bfedfff0.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="287" loading="lazy" src="data:image/svg xml,” width=”750″>

If your configuration is successful, you will be presented with a syncthing dashboard like the following:

<img alt="syncthing dashboard" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/09/echo/11-syncthing-dashboard-node1.png66e14bff0206e.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="431" loading="lazy" src="data:image/svg xml,” width=”750″>

Below you can see the syncthing dashboard from node2.

<img alt="node2 dashboard" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/09/echo/12-syncthing-dashboard-node2.png66e14bff64474.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="367" loading="lazy" src="data:image/svg xml,” width=”750″>

Connecting Syncthing Instance

At this point, you’ve finished the installation of syncthing on both Almalinux servers. It’s time to connect both syncthing instances, which can be done via the web administration dashboard.

On the node1 dashboard, click Action and select Show ID to get details of the node ID.

<img alt="show id" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/09/echo/13-show-id.png66e14bff83a62.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="162" loading="lazy" src="data:image/svg xml,” width=”385″>

You can see the ID and qrcode of the node1 instance. Copy the node1 ID, you will need it for connecting to the node2 instance.

<img alt="copy node1" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/09/echo/14-show-id.png66e14bffd054a.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="475" loading="lazy" src="data:image/svg xml,” width=”750″>

Now move to the node2 dashboard, on the Remote Devices section, click Add Remote Device.

<img alt="add remote device" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/09/echo/15-add-remote-device.png66e14bffe67a3.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="156" loading="lazy" src="data:image/svg xml,” width=”711″>

Paste the ID of node1, and input the name as node1.

<img alt="add device" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/09/echo/16-add-device.png66e14c003ded9.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="424" loading="lazy" src="data:image/svg xml,” width=”750″>

Next, move to the Sharing tab. In the Unshared Folders section, check the option Default Folder to share the target folder to the node1.

Also, be sure to check the Auto Accept option to automatically create or share folders that node1 advertises in the default path.

Click Save to confirm.

<img alt="share folder" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/09/echo/17-sharing-folder.png66e14c0077cdd.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="352" loading="lazy" src="data:image/svg xml,” width=”750″>

Move back to the node1 dashboard and you should see request messages from the node2. Click Add Device to confirm.

<img alt="accept device" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/09/echo/18-accept-device-node2.png66e14c008e03d.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="210" loading="lazy" src="data:image/svg xml,” width=”750″>

When prompted, click Save to confirm. Also, be sure to check the device ID of node2.

<img alt="confirm device node2" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/09/echo/19-node2-confirm-device.png66e14c00c00b7.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="329" loading="lazy" src="data:image/svg xml,” width=”750″>

Next, you will get another notification that the node2 instance will share the folder Default Folder, click Share to confirm.

Once the process is finished, you can see on the node1 the following information:

  • The Default Folder with path /home/tom/Sync is Shared With node2.
  • On the Remote Devices section, you can see the node2 with status Up To Date.

<img alt="remote device shared folder" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/09/echo/21-remote-device-upto-date.png66e14c00f3dc3.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="471" loading="lazy" src="data:image/svg xml,” width=”750″>

Now check the node2 dashboard, you should see similar information that the Default Folder is Shared With node1. Also, you can see on the Remote Devices section the node1 with status Up to Date.

Test File Sync

At this point, you’ve completed the configuration of the shared folder between two syncthing instances. Now, let’s try to create new files on the Shared directory to verify synchronization between two syncthing instances.

On the node1 server, move to the ~/Sync directory and execute the following command to create new files.

cd ~/Sync/

touch file{1..50}.txt
ls -ah

<img alt="node1 create files" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/09/echo/23-test-sync-node1.png66e14c0114502.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="159" loading="lazy" src="data:image/svg xml,” width=”750″>

Now move to the node2 server and go to the ~/Sync directory. Then, verify the list files on the ~/Sync directory.

cd ~/Sync

ls -ah

If your synchronization is successful, you should see files that you’ve created from the node1 server.

<img alt="check sync" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/09/echo/24-sync-success.png66e14c0129f25.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="137" loading="lazy" src="data:image/svg xml,” width=”750″>

With this, your syncthing installation is successful.

Conclusion

Congratulations! You have successfully installed syncthing on AlmaLinux 9 servers. You’ve also learned how to connect between syncthing instances, set up a shared folder, and verify the synchronization of syncthing instances.

From her, you can now add more devices and connect to your current instance to enable file sharing and synchronization between multiple devices.