Install Syncthing on Rocky 9 CentOS 9 Alma 9

In this guide, we will walk you through the process of installing and configuring Syncthing on Rocky 9, CentOS 9, or Alma 9. Syncthing is an open-source and cross-platform peer-to-peer synchronization software that allows you to securely synchronize files and folders between multiple devices in a network. It is considered a reliable and secure alternative to cloud-based file synchronization services like Google Drive and Dropbox.

Benefits of Syncthing

Before we dive into the installation process, let’s take a look at some key benefits of using Syncthing:

  1. Encryption: Syncthing ensures the security of your data by encrypting all communication between devices using TLS (Transport Layer Security). This encryption protects your files from unauthorized access.
  2. Cross-platform support: Syncthing is compatible with a wide range of platforms, including Linux, Windows, macOS, Android, and FreeBSD. This allows you to synchronize files between devices regardless of the operating system they are running on.
  3. Decentralization: Unlike cloud-based file synchronization services, Syncthing operates on a decentralized architecture. This means that devices communicate with each other directly over an encrypted channel, eliminating the need for a central server. With Syncthing, you have complete control over your data and are not reliant on third-party services to store your files.
  4. Versioning: Syncthing employs a sophisticated versioning system that ensures changes made to files are propagated correctly between devices, even if multiple changes are made simultaneously. This feature helps you keep track of file revisions and recover previous versions if needed.
  5. Selective synchronization: With Syncthing, you have the flexibility to choose which folders you want to synchronize between devices. This gives you greater control over your data and allows you to optimize storage space on your devices.
  6. Web-based GUI: Syncthing comes with a user-friendly web-based GUI (Graphical User Interface) that provides detailed information about the synchronization status of your files. It also offers tools for configuring advanced options such as service start/stop, device discovery, and LDAP integration.

Now that we have a clear understanding of the benefits of Syncthing, let’s proceed with the installation process.

Step 1: Download and Install Syncthing

To begin, you’ll need to download the latest stable release of Syncthing. You can find the release on the Github release page. Once you have the download link, you can use eitherwget orcurl to download the package. For example:

curl -s https://api.github.com/repos/syncthing/syncthing/releases/latest | grep browser_download_url | grep linux-amd64 | cut -d '"' -f 4 | wget -qi -

After the download is complete, extract the downloaded file using thetar command:

tar xvf syncthing-linux-amd64*.tar.gz

Next, copy the Syncthing binary file to the/usr/bin directory:

sudo cp syncthing-linux-amd64-*/syncthing /usr/bin/

To confirm that the installation was successful, check the version of Syncthing:

syncthing --version

Step 2: Create a Syncthing systemd unit file

To manage the Syncthing service using systemd, we need to create a systemd unit file. Follow the steps below to create the file:

  1. Create a user account for Syncthing:
   sudo useradd -m syncthing
  1. Add the user to the wheel group:
   sudo usermod -aG wheel syncthing
  1. Set a strong password for the Syncthing user:
   sudo passwd syncthing
  1. Create the systemd unit file:
   sudo vi /etc/systemd/system/[email protected]

Paste the following content into the file:

   [Unit]   Description=Syncthing - Open Source Continuous File Synchronization for %I   Documentation=man:syncthing(1)   After=network.target   StartLimitIntervalSec=60   StartLimitBurst=4   [Service]   User=%i   ExecStart=/usr/bin/syncthing serve --no-browser --no-restart --logflags=0   Restart=on-failure   RestartSec=1   SuccessExitStatus=3 4   RestartForceExitStatus=3 4   # Hardening   ProtectSystem=full   PrivateTmp=true   SystemCallArchitectures=native   MemoryDenyWriteExecute=true   NoNewPrivileges=true   [Install]   WantedBy=multi-user.target
  1. Reload systemd for the changes to take effect:
   sudo systemctl daemon-reload
  1. Start and enable the Syncthing service:
   sudo systemctl start syncthing@syncthing   sudo systemctl enable syncthing@syncthing
  1. Check the status of the service to confirm that it is running:
   systemctl status syncthing@syncthing

Step 3: Using a Separate Partition for Syncthing Data

By default, Syncthing stores its data in the user’s home directory. However, it’s recommended to use a separate partition for syncing data. Follow the steps below to configure a separate partition for Syncthing:

  1. Identify the partition you want to use for Syncthing data. In this example, we’ll use/dev/sdb:
   lsblk
  1. Create a partition table on the raw disk:
   sudo parted -s -a optimal -- /dev/sdb mklabel gpt   sudo parted -s -a optimal -- /dev/sdb mkpart primary 0% 100%   sudo parted -s -- /dev/sdb align-check optimal 1
  1. Create a filesystem on the partition. In this example, we’ll use XFS:
   sudo pvcreate /dev/sdb1   sudo vgcreate data /dev/sdb1   sudo lvcreate -n syncthing -l +100%FREE data   sudo mkfs.xfs /dev/data/syncthing   echo "/dev/data/syncthing /home/syncthing/data xfs defaults 0 0" | sudo tee -a /etc/fstab
  1. Create a mount point for the partition:
   sudo mkdir /home/syncthing/data
  1. Mount the partition:
   sudo mount -a
  1. Confirm that the partition is mounted:
   df -hT /home/syncthing/data
  1. Set the correct permissions for the data directory:
   sudo chown syncthing:syncthing /home/syncthing/data
  1. Verify the permissions:
   ls -lhd /home/syncthing/*

Step 4: Allow Required Ports in Firewall

If you have Firewalld active on your system, you need to allow ports 8384 and 22000 to enable Syncthing to function correctly. Run the following commands to allow these ports:

sudo firewall-cmd --add-port={8384,22000}/tcp --zone=public --permanentsudo firewall-cmd --reload

To confirm that the ports are allowed, you can use the following command:

firewall-cmd --list-all

Step 5: Accessing Syncthing Web UI

Once the Syncthing service is started, you can access the Syncthing web UI by opening your web browser and entering the following URL:

https://localhost_or_ServerIP:8384/

On the web UI, you can click on “Settings” to set a password for the admin user. This adds an extra layer of security to your Syncthing installation.

To test the login functionality, log in with the username “admin” and the password you set earlier.

In this guide, we have covered the installation and configuration of Syncthing on Rocky 9, CentOS 9, or Alma 9. Syncthing offers a secure and decentralized solution for synchronizing files and folders between multiple devices. With its cross-platform support, encryption, versioning system, and user-friendly web-based GUI, Syncthing provides users with complete control over their data and a reliable alternative to cloud-based file synchronization services. By following the steps outlined in this guide, you can easily set up and start using Syncthing on your system.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *