Learn how to – Install and Configure Syncthing on CentOS 8 / CentOS 7.
Syncthing is an open source continuous file synchronization used to sync files between two or more computers in a network. This tutorial is written to help you install and configure Syncthing on CentOS 8 / CentOS 7 Linux machine. Syncthing is easy to install, maintain and provides an easy way of sync files between computers in a local network and over the internet.
Core design principles of Syncthing
Syncthing is built with below core goals.
- Safe From Data Loss – Protecting the user’s data by ensuring there no corruption to user’s files.
- Easy to Use – Syncthing should be approachable, understandable and inclusive.
- Secure Against Attackers – Never allow the user’s data to be susceptible to eavesdropping or modification by unauthorized parties.
- For Individuals – Syncthing is primarily about empowering the individual user with safe, secure and easy to use file synchronization.
- Automatic – User interaction should be required only when absolutely necessary.
- Universally Available – Syncthing should run on every common computer.
Install Syncthing on CentOS 8 / CentOS 7
For CentOS and other family of RHEL Linux distribution, there is no officially supported repository which provides RPM packages for installation. Because of this, we’ll download and install Syncthing on CentOS 8 / CentOS 7 from official source archive.
Grab the latest release of Syncthing for your operating system:
curl -s https://api.github.com/repos/syncthing/syncthing/releases/latest | grep browser_download_url | grep linux-amd64 | cut -d '"' -f 4 | wget -qi -
Unpack the archive downloaded.
tar xvf syncthing-linux-amd64*.tar.gz
There will be a binary called syncthing in the folder created from extraction. Let’s copy the binary file to /usr/local/bin directory.
sudo cp syncthing-linux-amd64-*/syncthing /usr/local/bin/
Confirm the binary file is copied by checking Syncthing version.
$ syncthing --version
syncthing v1.23.4 "Fermium Flea" (go1.20.2 linux-amd64) teamcity@build.syncthing.net 2023-04-05 13:25:55 UTC
Configure Syncthing to Automatically Start on boot
We’ll use the Linux Systemd to manage the Syncthing service – enables users to start, stop, enable, and disable the service units.
Let’s create a new file.
sudo vi /etc/systemd/system/syncthing@.service
Paste below contents into the file.
[Unit]
Description=Syncthing - Open Source Continuous File Synchronization for %I
Documentation=man:syncthing(1)
After=network.target
[Service]
User=%i
ExecStart=/usr/local/bin/syncthing -no-browser -gui-address=0.0.0.0:8384 -no-restart -logflags=0
Restart=on-failure
SuccessExitStatus=3 4
RestartForceExitStatus=3 4
# Hardening
ProtectSystem=full
PrivateTmp=true
SystemCallArchitectures=native
MemoryDenyWriteExecute=true
NoNewPrivileges=true
[Install]
WantedBy=multi-user.target
Update systemd service list:
sudo systemctl daemon-reload
Enable and start the service.
sudo systemctl start syncthing@$USER
sudo systemctl enable syncthing@$USER
Confirm service status.
$ systemctl status syncthing@$USER
● syncthing@root.service - Syncthing - Open Source Continuous File Synchronization for root
Loaded: loaded (/etc/systemd/system/syncthing@.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2023-06-05 22:07:35 UTC; 2s ago
Docs: man:syncthing(1)
Main PID: 1635 (syncthing)
CGroup: /system.slice/system-syncthing.slice/syncthing@root.service
├─1635 /usr/local/bin/syncthing -no-browser -gui-address="0.0.0.0:8384" -no-restart -logflags=0
└─1642 /usr/local/bin/syncthing -no-browser -gui-address="0.0.0.0:8384" -no-restart -logflags=0
Jun 05 22:07:36 cent7.mylab.io syncthing[1635]: 2023/06/05 22:07:36 failed to sufficiently increase receive buffer size (was: 208 kiB, wanted: 2048 kiB, got: 416 kiB). See https://git...for details.
Jun 05 22:07:36 cent7.mylab.io syncthing[1635]: [E3OLA] INFO: TCP listener ([::]:22000) starting
Jun 05 22:07:36 cent7.mylab.io syncthing[1635]: [E3OLA] INFO: Relay listener (dynamic+https://relays.syncthing.net/endpoint) starting
Jun 05 22:07:36 cent7.mylab.io syncthing[1635]: [E3OLA] INFO: QUIC listener ([::]:22000) starting
Jun 05 22:07:36 cent7.mylab.io syncthing[1635]: [E3OLA] INFO: Completed initial scan of sendreceive folder "Default Folder" (default)
Jun 05 22:07:36 cent7.mylab.io syncthing[1635]: [E3OLA] WARNING: Failed starting API: listen tcp: address tcp/8384": unknown port
Jun 05 22:07:36 cent7.mylab.io syncthing[1635]: [E3OLA] INFO: Detected 0 NAT services
Jun 05 22:07:36 cent7.mylab.io syncthing[1635]: [E3OLA] INFO: Relay listener (dynamic+https://relays.syncthing.net/endpoint) shutting down
Jun 05 22:07:36 cent7.mylab.io syncthing[1635]: [E3OLA] INFO: QUIC listener ([::]:22000) shutting down
Jun 05 22:07:36 cent7.mylab.io syncthing[1635]: [E3OLA] WARNING: Starting API/GUI: listen tcp: address tcp/8384": unknown port
Hint: Some lines were ellipsized, use -l to show in full.
You can also use a separate user account to start service by replacing $USER with the name of user.
Accessing Syncthing UI
The Syncthing admin GUI is started automatically by systemd and is available on the Listen address configured, port 8384. If the -gui-address="ip:port"
option is not provided, the service will run on https://localhost:8384/
$ sudo ss -tunelp | grep 8384
tcp LISTEN 0 128 [::]:8384 [::]:* users:(("syncthing",pid=2194,fd=15)) ino:23328 sk:ffff9ede320e5280 v6only:0 <->
By default, the Syncthing admin interface is configured to allow remote access without a password.
Open the settings to set password: Settings > GUI
You’ll then be prompted to authenticate.
On accessing Syncthing GUI, you should see an interface like below:
Syncing data between two devices with Syncthing
For you to be able to sync data between two or more computers with
Syncthing, ensure Syncthing has been installed and configured on all
systems. Once setup is done, each device must be told about the other
device.
Syncthing Device ID
This is accomplished by exchanging “device IDs“. A
device ID is a unique, cryptographically-secure identifier that is
generated as part of the key generation the first time you start
Syncthing. Two devices will only connect and talk to each other if they
are both configured with each other’s device ID. Obtain Device ID from Actions > Show ID
Adding Syncthing Device ID
To get your two devices to talk to each other click “Add Remote Device” at the bottom right on both, and enter the device ID of the other side.
Also, select the folder(s) that you want to share. The device name is optional and purely cosmetic. It can be changed later if required. Once you click “Save” the new device will appear on right side of the GUI (although disconnected) and a prompt will be shown to indicate the need for a restart.
Note: The default folder being shared is ~Sync. When you have made changes like adding Sync directories, ensure you restart Syncthing on “Actions” > “Restart”.
Good luck and have fun! There is more documentation and if you run into trouble feel free to post a question in the support forum
Similar guides:
- How To Configure AWS S3 CLI for Ceph Object Gateway Storage
- Compress and Deduplicate Storage with Virtual Data Optimizer (VDO)
- Setup GlusterFS Storage With Heketi on CentOS 8 / CentOS 7
Leave a Reply
You must be logged in to post a comment.