This article presents a comprehensive guide detailing how to install and configure Syncthing on Debian VPS server. Upon conclusion, you will be able to install Syncthing on Debian VPS.
How to Install and Configure Syncthing on Debian VPS Server
Introduction
Overview of Syncthing
Syncthing is an open-source, decentralized file synchronization tool that allows you to sync files between multiple devices securely. Unlike cloud-based services, Syncthing gives you full control over where your data is stored and how it is shared.
Why Use Syncthing on a Debian VPS?
Running Syncthing on a Debian VPS allows you to have a secure, always-on server that can sync data between various devices, providing a reliable backup solution and a way to access files from anywhere.
Prerequisites
Before you begin, ensure that you have the following:
- A Debian VPS server with root or sudo access.
- Debian 10 (Buster) or Debian 11 (Bullseye) installed.
- Basic knowledge of the Linux command line.
- A configured SSH connection to your VPS (see guide).
Next, we will install Syncthing on a Debian server by following the steps outlined below:
Step 1: Update Your System
Login to the VPS via SSH and start by ensuring your system’s package list is up to date.
sudo apt update
Then, upgrade the installed packages to their latest versions:
sudo apt upgrade -y
Step 2: Install Syncthing
Adding Syncthing’s APT Repository
To get the latest version of Syncthing, add its official APT repository.
curl -s https://syncthing.net/release-key.txt | sudo apt-key add - echo "deb https://apt.syncthing.net/ syncthing stable" | sudo tee /etc/apt/sources.list.d/syncthing.list
Update your package list again:
sudo apt update
Installing Syncthing
Now, install Syncthing:
sudo apt install syncthing -y
Step 3: Configuring Syncthing
Initial Setup
After installation, run Syncthing to generate the initial configuration and keys:
syncthing
This command will also provide the URL to access the Web GUI, typically http://127.0.0.1:8384
.
Accessing the Web GUI
To access the Syncthing Web GUI from your local machine, you need to set up an SSH tunnel or configure Syncthing to listen on your VPS’s public IP address.
To bind Syncthing to all network interfaces, edit the configuration file:
nano ~/.config/syncthing/config.xml
Find the <address>
element under <gui>
and change it to:
<address>0.0.0.0:8384</address>
Restart Syncthing to apply the changes:
syncthing -restart
You can now access the Web GUI at http://your-server-ip:8384
.
Step 4: Running Syncthing as a Service
Setting Up Systemd Service
To ensure Syncthing starts automatically on boot, create a systemd service file:
sudo nano /etc/systemd/system/syncthing@.service
Add the following content:
[Unit] Description=Syncthing - Open Source Continuous File Synchronization Documentation=man:syncthing(1) After=network.target [Service] User=%i ExecStart=/usr/bin/syncthing serve --no-browser --gui-address "0.0.0.0:8384" Restart=on-failure SuccessExitStatus=3 4 RestartForceExitStatus=3 4 RestartSec=5 [Install] WantedBy=multi-user.target
Enabling and Starting the Service
Replace username
with your actual username and enable the service:
sudo systemctl enable syncthing@username.service sudo systemctl start syncthing@username.service
Check the status to ensure it’s running:
sudo systemctl status syncthing@username.service
Step 5: Configuring Firewall
If you have UFW or Iptables configured on your server, you need to allow Syncthing’s port (8384 by default).
UFW
sudo ufw allow 8384/tcp
Iptables
sudo iptables -A INPUT -p tcp --dport 8384 -j ACCEPT
Verifying Open Ports
Check if the port is open:
sudo netstat -tuln | grep 8384
Step 6: Securing Syncthing
Setting Up Authentication
To prevent unauthorized access, set up authentication in the Syncthing Web GUI under Settings > GUI.
Enable GUI Authentication and create a username and password.
Configuring TLS
For added security, enable HTTPS by providing a valid SSL certificate or using a self-signed certificate. You can configure these in the same GUI Settings section.
9. Step 7: Advanced Configuration
Syncing Specific Folders
In the Web GUI, go to Add Folder and select the directory you want to sync. You can customize folder paths and other settings according to your needs.
Adding Remote Devices
To sync with other devices, go to Add Remote Device in the Web GUI. Enter the device ID of the other device you want to sync with and configure the settings as needed.
Step 8: Monitoring and Maintaining Syncthing
Checking Logs
Monitor Syncthing logs for any issues:
journalctl -u syncthing@username.service
Updating Syncthing
Keep Syncthing updated to the latest version by periodically running:
sudo apt update sudo apt upgrade syncthing -y
Backing Up Configuration
To back up your Syncthing configuration:
tar czvf syncthing-config-backup.tar.gz ~/.config/syncthing
Store the backup file in a safe location.
Conclusion
Running Syncthing on a Debian VPS offers a secure and flexible solution for synchronizing files across multiple devices. By following this guide, you’ve installed and configured Syncthing to start syncing files effectively. For more advanced features and troubleshooting, refer to the official Syncthing documentation.
This guide provides a comprehensive step-by-step process to install and configure Syncthing on Debian VPS. If you need further assistance, consult Syncthing’s community forums or documentation for additional support.