How to Install Syncthing on Ubuntu 22.04 LTS

Syncthing is a free, open-source, peer-to-peer file synchronization application. Syncthing can sync files between devices on a local network or between remote devices over the Internet, with all data transmitted between multiple devices encrypted with TLS. Whenever you create, modify or delete data on one peering node, the application will automatically replicate the changes to other servers. Another popular feature is Syncthing being cross-platform and available on Windows, macOS, Linux, Android, Solaris, Darwin, and BSD making it possible to sync multiple devices.

In the following tutorial, you will learn how to securely import the official repository from Syncthing’s official APT repository and install Syncthing on Ubuntu 22.04 LTS Jammy Jellyfish using the command line terminal with optional stable or candidate (pre-release) to select from.

Update Ubuntu

First, update your system with the following command to ensure all packages are up-to-date to avoid conflicts.

sudo apt update && sudo apt upgrade -y

Install Required Packages

The following packages must be installed to assist in installing the database software.

sudo apt install software-properties-common apt-transport-https wget curl -y

Import Syncthing Repository

Syncthing is in the default Ubuntu repositories but is not as up-to-date as many would like. Instead, you will install the official source deb repository.

First, add the GPG key by executing the following command:

sudo curl -s -o /usr/share/keyrings/syncthing-archive-keyring.gpg https://syncthing.net/release-key.gpg

Next, import the repository of the version you wish to install. For most users, this should be the stable version, but for those who love to live on the edge and use bleeding edge, the candidate version (pre-release) version may be better.

Import Syncthing Stable

echo "deb [signed-by=/usr/share/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing stable" | sudo tee /etc/apt/sources.list.d/syncthing.list

Import Syncthing Candidate (Pre-Release)

echo "deb [signed-by=/usr/share/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing candidate" | sudo tee /etc/apt/sources.list.d/syncthing.list

Install Syncthing

Once you have imported your desired Syncthing version repository, run a quick APT update to reflect the new additions.

sudo apt update

Next, install Syncthing using the following command.

sudo apt install syncthing -y

Next, confirm Syncthing was installed correctly using the following command.

syncthing --version

Example output:

How to Install Syncthing on Ubuntu 22.04 LTS

Configure Syncthing Systemd Service

When you installed Syncthing, the systemd file was created under the location (/lib/systemd/system). Under this directory, you will find the (syncthing@.service) file. The way Syncthing works is that you need to enter the username of the account between the (@) and the (.service), for example (syncthing@linuxcapable.service).

To kick start and enable Syncthing, you need to execute the following command.

sudo systemctl enable syncthing@username.service

Now that the service is enabled on startup, you need to start it manually this one time by executing the following:

sudo systemctl start syncthing@username.service

Example with my username:

sudo systemctl start syncthing@joshua.service

Now, you should check the status by typing the following command.

systemctl status syncthing@username.service

Example again with my username:

systemctl status syncthing@joshua.service

Example output:

How to Install Syncthing on Ubuntu 22.04 LTS

Note, your configuration files are under (/home/username/.config/syncthing/) and your default home folder is (/home/username/syncthing/). You can change the home folder later on if you choose. 

The main configuration file is located at (/home/username/.config/syncthing/config.xml) if you need to change or fix any settings, such as changing the default 127.0.0.1 to an internal or external IP address.

Configure UFW Firewall

Syncthing will need to be allowed to use port (22000) to communicate with peers. If you are using UFW, execute the following command to enable the port.

sudo ufw allow 22000/tcp

For newer users that would like to use UFW, enable it using the following command.

sudo ufw enable

For more information on UFW, visit my tutorial How to Install & Configure UFW Firewall on Ubuntu 22.04 LTS“.

Connect to Syncthing WebUI

Syncthing Peers

To use Syncthing, you will need to install a second copy up to this point on another server or desktop. The most fantastic part about Syncthing is that you can install it not just on Linux but on multiple operating systems.

Note, if you are using Syncthing to back up to another platform that is not Linux, make sure to set (receive) only as the file permissions going to and from will cause issues.

Syncthing listens to (127.0.0.1:8384) locally by default which you can access in your web browser. Type in the following in your Internet Explorer address bar:

http://127.0.0.1:8384

The first time you up the WebUI, you will notice a pop-up asking (Allow Anonymous Usage Reporting?).

Select an option to proceed.

Example:

How to Install Syncthing on Ubuntu 22.04 LTS

After sorting out the usage reporting, you will be prompted with a (GUI Authentication: Set User and Password) notification. It is crucial to secure your Syncthing service, so you should immediately hit (Settings) to proceed to the configuration page.

Example:

How to Install Syncthing on Ubuntu 22.04 LTS

Next screen, select the (GUI) as shown below.

Example:

How to Install Syncthing on Ubuntu 22.04 LTS

Now, set up a (username) and (password). Also, in this part, you can set (HTTPS) for GUI use if you prefer.

Once you have finished, press the (Save) button on the bottom right corner.

Example:

How to Install Syncthing on Ubuntu 22.04 LTS

Now is the time to repeat the above guide on a second peering operating system to move to the next part of the guide, which requires (two) Syncthing clients.

Syncing Files & Folders between Devices

Now you have installed two or more Syncthing clients on various devices and operating systems, and now you can set up syncing files or folders between the devices.

First off, in the WebUI on (peering node 1), you can click (Actions > Show ID) in the upper-right hand corner, and you will find the device ID, which is a long string of letters and numbers.

How to Install Syncthing on Ubuntu 22.04 LTS

You can also see the QT code and the device ID, and it is used for Syncthing on smartphones and tablets.

Example:

How to Install Syncthing on Ubuntu 22.04 LTS

The next step is copying the (Device Identification) which in the guide example is (CAL3FN4-R72LBTK-Q3ZFAEC-OUOAIEM-ZOJIMQ3-JHG5OCK-ZSJORVA-64552A3) from the WebUI interface of the node you want the files to sync from first which was named (peering node 1).

Next, you open the WebUI of the second peering device (peering node 2) and click (Add Remote Device) on the bottom right-hand corner where the device ID is located, give the new device a name, and then click the (Save) button to proceed.

Example:

How to Install Syncthing on Ubuntu 22.04 LTS

Now back on (peering node 1), you will see (peering node 2) attempting to connect. If you do not see it, refresh your page and ensure UFW or a similar firewall does not block it.

Click (Add Device) to continue.

Example:

How to Install Syncthing on Ubuntu 22.04 LTS

Once you click to add the device, a new screen will appear (peering node 1). Here, you can automatically change the device’s default name, share files and directories in the sharing panel, and more.

Click (Save) to continue.

Example:

How to Install Syncthing on Ubuntu 22.04 LTS

Now both nodes are connected. You can now share a directory between the devices. For example, (peering node 1) has a folder you want to sync between itself and (peering node 2).

The first click adds a folder on (peering node 1).

Example:

How to Install Syncthing on Ubuntu 22.04 LTS

For the guide, the example used the (Downloads) directory to sync between the devices, and you can give the folder you want to sync to (peering node 2) a unique ID (name).

For the tutorial, this was named the ID (downloads-backup) and set the path. Do not click save just yet.

Click (Sharing) in the top row to continue.

Example:

How to Install Syncthing on Ubuntu 22.04 LTS

In the (Sharing) panel, click the remote device to share with. Our example below is (peering node 2), then click save to continue.

Example:

How to Install Syncthing on Ubuntu 22.04 LTS

In (peering node 1), you will notice the folder scanning itself, which is fine. Now, switch back over the (peering node 2), and you will see a new pop up with (peering node 1) wanting to send the (Downloads) directory.

Click add as the following demonstrates.

Example:

How to Install Syncthing on Ubuntu 22.04 LTS

Now a new pop-up will show on (peering node 2). Here, you can change your path if need be and adjust any other options in the top pane. For now, click save to see the sync process begin:

How to Install Syncthing on Ubuntu 22.04 LTS

Now it may take a minute or so, but the devices should start syncing.

Example:

How to Install Syncthing on Ubuntu 22.04 LTS

Congratulations, you have successfully used Syncthing to sync two devices! If you see the following error (Failed to create folder marker: mkdir .stfolder: read-only file system), see the next step to fix permissions. Once corrected, restart the syncthing service, and it should start the process.

Configure Syncthing Permissions

Syncthing can sometimes run into issues with sending and receiving between remote nodes. With Linux systems, you can install the package (setfacl) by entering the following command.

sudo apt install acl -y

Then execute the following command with your username.

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

If you constantly come into trouble with this as files change frequently, you can set a cron job up as below:

sudo crontab -e

Then add for syncing permissions every 5 minutes:

*/5 * * * * sudo setfacl -R -m u:username:rwx /folder/path/ -n

The second feature is to set (Ignore Permissions) in the (Advanced) options in Syncthing WebUI. This can fix issues as well but do note the above step with (setfacl) will most likely need to be done in conjunction with this feature.

Example:

How to Install Syncthing on Ubuntu 22.04 LTS

Configure Send-Only & Receive-Only Folders

A great feature with Syncthing is that you can specify the peering nodes to send and receive. However, they also can send only and receive only, giving you ultimate flexibility. To do this, open up (Advanced) in the top panel of the folder currently in sync and see (Folder Type) to change to receive, send, or both.

Example:

How to Install Syncthing on Ubuntu 22.04 LTS

Remember to click save.

Configure Syncthing Adjust Scan Intervals

If you do not require syncthing to watch for changes constantly and free up the CPU, you can disable (Watch for Changes) in the (Advanced) section in editing the syncing folder between devices.

Also, by default, a full re-scan is scheduled for each hour to sync changes hourly and be adjusted longer or shorter.

Example:

How to Install Syncthing on Ubuntu 22.04 LTS

Configure Nginx as a Reverse Proxy for Syncthing

Suppose you like to set up Syncthing to Nginx as a reverse proxy to access your server. This can be done using the following steps.

First, install the custom Nginx PPA from Ondřej Surý, which is updated with better features:

Latest Nginx Stable:

sudo add-apt-repository ppa:ondrej/nginx && sudo apt update -y

Latest Nginx Mainline:

sudo add-apt-repository ppa:ondrej/nginx-mainline && sudo apt update -y

Now update your sources list.

sudo apt update

Next, install Nginx:

sudo apt install nginx-core nginx-common nginx nginx-full -y

You will need to create a server block or otherwise virtual host from Apache familiar users. To do this, execute the following command.

sudo nano /etc/nginx/sites-available/syncthing.conf

Add the following code in the (syncthing.conf) file.

server {
  listen 80;
  server_name syncthing.example.com;

  access_log /var/log/nginx/syncthing.access.log;
  error_log /var/log/nginx/syncthing.error.log;
  location / {
    proxy_pass http://127.0.0.1:8384;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;

### IP LOCKDOWN FOR MORE SECURITY, UNCOMMENT TO USE WITH YOUR OWN IP ADDRESSES###
# allow from <ip>;
# deny all;

  }
}

Change the “proxy_pass” if you configure a more advanced differently to the tutorial, or else the reverse proxy will not work.

Save the file (CTRL+O) and then (CTRL+X) to exit.

Next, test your Nginx configuration by running the command.

sudo nginx -t

If everything is correct with no errors, you will get the following output:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

To finish off, reload or restart your Nginx service:

sudo systemctl restart nginx

From this point, you can access the Syncthing server using the URL http://syncthing.example.com or the external server <IP> address if you do not have a domain name.

Comments and Conclusion

Overall, Syncthing has quite an extensive list of options, and the guide has only touched on some of the possibilities it is truly capable of. The software is under constant development and is a good choice for users that need simple sync software with a friendly WebUI.

A note to users that have Linux and Windows devices, you cannot have the (Send and Receive) option on, as Windows does not save the file permissions of Linux, and if Windows sends a file back, it will cause sync issues with (permission) denied. Make sure you only send or receive if used in this setup.

For more information, visit the Syncthing documentation.



Follow LinuxCapable.com!

Like to get automatic updates? Follow us on one of our social media accounts!