How to Install Syncthing on Linux Mint 20

This tutorial will show you how to install Syncthing on Linux Mint 20. Syncthing is a free, peer-to-peer continuous file synchronization program that allows you to synchronize your files across multiple devices, available for Linux, BSD, macOS, Windows, Android, iOS and Solaris.

It’s an open-source alternative to the popular Resilio Sync (formerly known as BitTorrent Sync) application. The creation, modification or deletion of files on one machine will automatically be replicated to your other devices. Syncthing does not upload your files to a central server like Nextcloud, but exchange your data directly between your devices. All your data is encrypted with TLS when transmitting between your devices.

How to Install Syncthing on Linux Mint

Syncthing Features

  • Free & open source.
  • Fast syncing speed.
  • Supports one-way syncing.
  • Selective Sync (Ignore patterns).
  • It can use relay servers if two peers can’t connect to each other.
  • Supports LDAP authentication.

Table of Contents

Install Syncthing on Linux Mint 20 via Official Deb Repository

Syncthing is included in the default Linux Mint repository. However, it’s recommended to install Syncthing from the upstream official repository, so you will get the latest version.

Open a terminal window and use curl to download the GPG key then import the key with apt-key.

sudo apt install curl

curl -s https://syncthing.net/release-key.txt | sudo apt-key add -

If you see OK in the terminal, that means the GPG key is successfully imported. Then add the official deb repository with the following command.

echo "deb https://apt.syncthing.net/ syncthing stable" | sudo tee /etc/apt/sources.list.d/syncthing.list

Because this repository uses https, we need to install the apt-transport-https package, so the APT package manager can establish https connection with this repository.

sudo apt install apt-transport-https

Update local package index and install syncthing on Linux Mint.

sudo apt update

sudo apt install syncthing

Set Up Syncthing as a Systemd Service

The official Syncthing deb package ships with the needed systemd service file. Under /lib/systemd/system/ directory, you will find a [email protected] file. Enable syncthing to auto start at boot time by running the below command. Replace username with your actual username.

sudo systemctl enable [email protected]username.service

The above command will create a symbolic link that points to the [email protected] file.

Created symlink from /etc/systemd/system/multi-user.target.wants/[email protected] to /lib/systemd/system/[email protected]

Now we can start the Syncthing service with the following command.

sudo systemctl start [email protected]username.service

Check status

systemctl status [email protected]username.service

Output:

syncthing linux mint

Hint: If the above command doesn’t quit immediately, press Q to gain back control of the terminal.

We can see that Syncthing autostart is enabled and it’s running.

The syncthing systemd service creates configuration files under /home/username/.config/syncthing/ and a folder /home/username/Sync as the default sync folder. The main config file is /home/username/.config/syncthing/config.xml.

Install Syncthing on other OS

Go to Syncthing download page and install Syncthing on other operating systems like Windows, macOS, BSD, Android. Currently there’s is no official client for iOS. You can use the third-party app MobiusSync.

Configure Firewall

Syncthing uses port 22000 to communicate with peers. If your computer or server enabled the UFW firewall, then you need to allow port 22000 with the following command.

sudo ufw allow 22000/tcp

Accessing the Syncthing Web Interface

By default, Syncthing service listens on 127.0.0.1:8384. Now in your Web browser’s address bar, type 127.0.0.1:8384 to access the Syncthing Web interface. You can add other Syncthing devices and share folders with them.

linux mint-syncthing-web-interface

Start Syncing Files between Your Devices

Once we have two devices running Syncthing, we can start syncing files between them.

In the Syncthing web interfce, click on Actions > Show ID on the upper-right corner. You will see the device ID, which is a long string of letters and numbers. The QR code, which is also the device ID, is used for configuring Syncthing on smartphones.

Syncthing Device ID

Copy the device ID, then open the Syncthing Web interface of the second device, click Add Remote Device on the bottom-right corner. Then paste the Device ID and give the device a name. Click the Save button.

Syncthing add remote device

Now the second device will try to connect to the first device. Refresh the Web interface on the first device, you will see the following message. Click Add Device to add the second device to the device list of the first device.

Syncthing add device

Now the two devices are connected.

On the left pane of Web interface is the default sync folder (/home/username/Sync). Click the Add Folder button to add a new folder. Give a descriptive label for this folder and set the folder path.

syncthing add new folder

Syncthing runs as your own user account, so you need to have write permission on the shared folder. If you see the following error message while sharing a folder, it means you don’t have write permission on that folder.

2020-06-21 20:05:49: Failed to create folder marker: mkdir .stfolder: read-only file system

You can grant write permission with setfacl.

sudo apt install acl
sudo setfacl -R -m u:username:rwx /folder/path/

Note: If the problem still persists, please see the troubleshooting tips at the end of this article.

In the Sharing tab, select your other Syncthing device.

syncthing sharing devices

In the Ignore Pattens tab, you can enter the name patterns for files that should not be synchronized.

In the Advanced tab, you can choose the folder type, rescan interval, etc.

sycnthing advanced sharing settings

Click Save button to begin syncing. A message will appear in the Web interface of the other device. Click Add to receive files.

syncthing add share folder

Now the two devices are syncing files. On the right side, you can see the download rate, upload rate, local folder size, etc.

syncthing check sycning progress

Enable User Authentication

By default, anyone who have access to your computer can access your Syncthing web interface. We can enable user authentication to restrict access. Click the Actions button on the upper-right corner, then select Settings -> GUI.

install syncthing on Debian 8

Enter a username in GUI Authentication User field, enter a password in GUI Authentication Password field. Then save your settings.

syncthing gui user authentication

Once you save the changes, restart Syncthing systemd service, or you might see a 502 bad gateway error when reloading the page.

sudo systemctl restart [email protected]username.service

Now log into the Syncthing Web interface with your new username and password.

Send-Only & Receive-Only Folders

When sharing a folder in Syncthing, you can go to the Advanced tab and choose one of three folder types:

  • Send & Receive (default)
  • Send Only
  • Receive Only

You might want to choose send-only or receive-only. For example, If you have 3 computers: A, B, and C, and you want to aggregate folders on computer A and B to a single folder on computer C. Then you can set the folder type to receive-only on computer C. In this way, computer C will have all of the files in a single folder. Computer A and B still have the original files. No more and no less.

syncthing folder type

When you use the same folder path on computer C, Syncthing might warn you that “this path is a subdirectory of an existing folder”. You can ignore this warning because you have a receive-only folder. Existing files in the folder won’t be deleted.

Syncing via Relay Servers

If two Syncthing instances can’t connect to each other, then Syncthing will try to use a relay server to transfer files.

syncthing

A common reason why they can’t connect to each other is that both of them are behind NAT devicse and didn’t configure port forwarding. Once you configure port forwarding, you can disable relay servers. Here’s how. Click the Edit button and select the Advanced tab, Change the address from dynamic to tcp://ip-address:22000. Of course you need to use your real IP address.

syncthing disable relay servers

Syncing Large Amounts of Small Files

Syncthing isn’t suitable for syncing large amounts of small files like osm tile files, because it will quickly hit the Linux file system inotify limits. If the two devices both run Linux, then you can use the rsync (remote sync) tool to sync large amounts of small files, like this:

rsync -aP /path/to/source/folder/  [email protected]:/path/to/destination/folder

Troubleshooting Tips

Unable to connect

If your Syncthing instances can’t connect to each other, you can use the ss (socket stats) utility to check if Syncthing is listening on TCP port 22000.

sudo ss -lnpt | grep syncthing

As you can see from the screenshot below, my Syncthing is listening on port 8384 (web interface) and 22000 (peer-to-peer connection).

linux mint-syncthing-listen-port-22000

If not, you can edit the configuration file.

nano ~/.config/syncthing/config.xml

Find the following line.

<listenAddress>default</listenAddress>

Change default to tcp://your-IP-address.

<listenAddress>tcp://12.34.56.78</listenAddress>

Save and close the file. Then restart Syncthing.

sudo systemctl restart [email protected]username.service

Failed to Create Folder Marker

If you want to sync a system folder such as /etc/, you will probably see the following error message:

Failed to create folder marker, read-only file system

This is because the syncthing systemd service (/lib/systemd/system/[email protected]) has the following ProtectSystem variable that forbids write operation on systemd folders (/usr/, /boot/, /etc/).

ProtectSystem=full

We can add exclusions, so Syncthing can write to the folder. Create a folder to store our custom systemd configurations.

sudo mkdir /etc/systemd/system/[email protected]username.service.d/

Then create a file under this directory.

sudo nano /etc/systemd/system/[email protected]username.service.d/permission.conf

Add the following lines in this file.

[Service]
ReadWritePaths=/shared/foler/one/  /shared/foler/two/

Folders are separated by empty space. You can add as many folders as you like. The folder must exist on your system, or Syncthing will fail to restart.

Save and close the file. Then reload systemd.

sudo systemctl daemon-reload

And restart Syncthing.

sudo systemctl restart [email protected]username.service

The Folder Size in Global State is inaccurate

This can happen if you share folders with multiple devices. Let’s say you share a folder from device 1 to device 2. If device 2 isn’t finished syncing files and you share the folder from device 2 to device 3, then the global folder size displayed on device 3 will be smaller than the actual size.

Folder Synchronization Stops

Check the Syncthing logs to find out why it stopped syncing.

sudo journalctl -eu [email protected]

Problem Processing Requests

If you see the following error, you can check the Nginx error log (/var/log/nginx/syncthing.error.log) or the Apache error log (/var/log/apache/syncthing_error.log) to find out what caused this problem.

Syncthing seems to be experiencing a problem processing your request. Please refresh the page or restart Syncthing if the problem persists.

In my case, it’s because I enabled ModSecurity web application firewall.

Asynchronous Replication

Note that Syncthing uses the asynchronous method, so changes made on one node will take some time to replicate to other nodes. If your application is sensitive to sync delay, it’s recommended to designate a node as the master node. Make changes on the master node only and use the slave nodes as a backup.

Wrapping Up

I hope this tutorial helped you install and use Syncthing on Linux Mint. As always, if you found this post useful, then subscribe to our free newsletter to get more tips and tricks. Take care 🙂

Rate this tutorial
[Total: 1 Average: 5]

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community (https://community.linuxbabe.com) for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here