Mustafa Can Yücel

Setting Up Your Debian Server 5: Syncthing

Syncthing is a free, open-source peer-to-peer file synchronization application available for Windows, macOS, Linux, Android, Solaris, Darwin, and BSD. It can sync files between devices on a local network, or between remote devices over the Internet. Data security and data safety are built into its design.

You can use Syncthing as a cloud service; it is possible to synchronize password databases (Keepass, etc.), documents, photos, videos, and other files between your devices. You can also use it to share files with your friends. To install it on our server, we will use the following commands:

sudo apt-get update
# Add the release PGP keys:
sudo curl -o /usr/share/keyrings/syncthing-archive-keyring.gpg

# Add the "stable" channel to your APT sources:
echo "deb [signed-by=/usr/share/keyrings/syncthing-archive-keyring.gpg] syncthing stable" | sudo tee /etc/apt/sources.list.d/syncthing.list

# Add the "candidate" channel to your APT sources:
echo "deb [signed-by=/usr/share/keyrings/syncthing-archive-keyring.gpg] syncthing candidate" | sudo tee /etc/apt/sources.list.d/syncthing.list

# Update and install syncthing:
sudo apt-get update
sudo apt-get install syncthing
Then we configure Syncthing to run as a service by creating a systemd service file with the command sudo vi /etc/systemd/system/syncthing@.service and the following content:
Description=Syncthing - Open Source Continuous File Synchronization for %I

ExecStart=/usr/bin/syncthing -no-browser -gui-address="server_ip:8384" -no-restart -logflags=0
SuccessExitStatus=3 4
RestartForceExitStatus=3 4

In the above example, do not forget to set your ip in the -gui-address section. We have set the port to 8384. You can change it to any port you want, but we need to enable it in the firewall. To do this, we will use the following commands:
sudo ufw allow 8384/tcp
Then we will update the service list, then enable and start the service with the following commands:
sudo systemctl daemon-reload
sudo systemctl start syncthing@$USER
sudo systemctl enable syncthing@$USER
systemctl status syncthing@$USER

The GUI of Syncthing comes without a password, so we immediately go to serverIP:8384 with a browser and set up a GUI password by following the directions on the page.

Note From the Future

I strongly advise you to use Caddy instead of Apache for reverse-proxying Syncthing port 8384. It is much easier to set up and use. For setting up Caddy, you can skip to Switching to Caddy Server post.

In the next part, we will install NextCloud on our server.