Install Syncthing on Ubuntu
As the title implies, I just want to install Syncthing on one of my Ubuntu server to serve as a cloud node of my whole Syncthing cluster. And this blog will record some issues and points that I faced while this process.
Installation
Since I'm using Ubuntu, the "Installation" part becomes really easy. All we need to do is to follow the official guide on website: https://apt.syncthing.net/
Create New User
It's recommended by the official docs to create a new user for syncthings.
useradd syncthing
passwd syncthing # optional, set password for this new user
After creating new user, you could switch to it using:
su - syncthing
Grant Permission
One core thing is that the created user used by Syncthing must have full access to all local folders path that you used to sync files at.
You could use the following command to transfer ownership of a directory to this new user (and the newly created group correspond to this user) using the following command:
chown -Rh syncthing:syncthing /some/path/you/want/to/transfer/ownership/to
- R: Recursive.
- h: Deal with symbolic link.
Checkout chown manual for more info.
Allow Remote Access To GUI
Be default, the Web GUI served using following config:
127.0.0.1:8384
Which means:
- The port is
8384
- You could only access this Web GUI from your local machine (we don't want this limitation because we run this Syncthing instance on a server)
So we need to manually change this in config file. The path should be the following in Ubuntu:
$HOME/.local/state/syncthing
Notice that different user could have different
$HOME
as their env, you could check it using the commandecho $HOME
After get to the the file $HOME/.local/state/syncthing/config.xml
, (in my case, is /home/syncthing/.local/state/syncthing/config.xml
), we change:
<configuration>
...
<gui>
<address>0.0.0.0:30002</address>
</gui>
...
</configuration>
The schema of the config could changed in newer version of syncthing, read official docs if you face issues.
Create Service For Syncthing
Also, there is an official guide for this: https://docs.syncthing.net/users/autostart.html#linux
Reuse Existing Configuration
As we said above, configurations are stored at $HOME/.local/state/syncthing
, so if it possible for us to reuse this configurations?
Yes, but we need to be careful. All sync folders and it's local path (Including those created locally but not have any remote sharing relationship, or, Unused folders) are stored inside the configurations. And the new environment should have the full access to all local path used by these folders in configurations.
No comment