Install Syncthing to run as a service on Ubuntu or Debian

Syncthing is a continuous file synchronization program. It synchronizes files between two or more computers in real time, safely protected from prying eyes. Your data is your data alone, and you deserve to choose where it is stored, whether it is shared with some third party, and how it's transmitted over the internet. Syncthing is great for small businesses and Home office networks. Syncthing works on Linux / Windows / Apple / Android and IOS

Setting up your own Syncthing server is really simple and easy to do. In order to Install Syncthing to run as a service or daemon on an Ubuntu or Debian Server, you will need to install syncthing as per the instructions on the syncthing website. Then setup the systemd to start and run all the time. Next simply setup the web GUI Interface and you are good to go.

3 Easy Steps

  1. Install Syncthing.
  2. Start / Run and Configure the systemd daemon.
  3. Setup the Web GUI Interface.

1. Install Syncthing as per instructions on Website

To allow the system to check the packages authenticity, you need to provide the release key.

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

The stable channel is updated with stable release builds, usually every first Tuesday of the month.

# Add the "stable" channel to your APT sources:
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

The candidate channel is updated with release candidate builds, usually every second Tuesday of the month. These predate the corresponding stable builds by about three weeks.

# Add the "candidate" channel to your APT sources:
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

To make sure the system packages do not take preference over those in this repository, you need to adjust the priority/preference.

# Increase preference of Syncthing's packages ("pinning")
printf "Package: *\nPin: origin apt.syncthing.net\nPin-Priority: 990\n" | sudo tee /etc/apt/preferences.d/syncthing

And finally.

# Update and install syncthing:
sudo apt update
sudo apt install syncthing

Depending on your distribution, you may see an error similar to the following when running apt-get:

E: The method driver /usr/lib/apt/methods/https could not be found.
N: Is the package apt-transport-https installed?
E: Failed to fetch https://apt.syncthing.net/dists/syncthing/InRelease

If so, please install the apt-transport-https package and try again:

sudo apt install apt-transport-https

2. Install a systemd Unit for Syncthing

The instructions to install the Systemd unit for syncthing is on their github site at

https://github.com/syncthing/syncthing/tree/main/etc/linux-systemd

Get the Systemd file from Github

wget https://raw.githubusercontent.com/syncthing/syncthing/main/etc/linux-systemd/system/syncthing%40.service

Change the owner of the file to root

sudo chown root: [email protected]

Move the file to /etc/systemd/system/

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

Reload the systemd daemon

sudo systemctl daemon-reload

Enable the syncthing daemon to run as a user

sudo systemctl enable syncthing@ron

Start the syncthing daemon

sudo systemctl start syncthing@ron

Check to see if the syncthing daemon is running

sudo systemctl start syncthing@ron

3. Configure the Web interface for your Syncthing Server

The Syncthing GUI (web interface) listens on a single TCP port for HTTP and HTTPS connections. By default this address is 127.0.0.1:8384. The 127.0.0.1 part means “localhost” which means it only listens for connections from the same computer Syncthing is running on. This is a reasonably safe default as it means you need to be logged in on the computer to access the GUI - it cannot be accessed from the network.

To allow access from the network, change the listen address to 0.0.0.0:8384, where “0.0.0.0” means roughly “anywhere”. You should then also set a username and a strong password for authentication and check the option to use HTTPS. You are otherwise, potentially, opening up your Syncthing installation for the world.

This config file is located at ~/.config/syncthing/config.xml

nano ~/.config/syncthing/config.xml

After you have edited the listen address to 0.0.0.0:8384 . restart syncthing with this command

sudo systemctl restart syncthing@ron

That's it. you should now have syncthing running on your server as a daemon. You should now be able to configure your server by accessing the web GUI at http://your-server-ip:8384

Enjoy!

Clustered Networks

Located in Edmonton, AB Canada, Clustered Networks was Incorporated in 2001 and has offered Network / Internet and IT Consulting services for over 20 years. We offer personalized service! Call Us Today! - Click Here for our Contact Info

#syncthing #homeserver #raspberrypi

Posted in Linux Network Admin Tips, Network Security Tips, Tech How To on Jun 22, 2021