Creating a separate user for syncthing

Hi everyone,

I am trying to create a separete user for syncthing in Linux and experiencing some difficulties as far as access to the files goes. I would like to hear how others have done this.

CREATE USER AND GROUP

useradd --system --user-group --home-dir /home/syncthing --shell /sbin/nologin syncthing

CREATE SYNCTHING STORAGE

mkdir -p /home/syncthing chown -R syncthing:syncthing /home/syncthing

ADD ANOTHER USER TO syncthing GROUP

usermod -a -G syncthing another_user

SETTING UP PERMISSIONS

The fun part comes with permissions.

Computer A (RECEIVE ONLY): chmod -R 750 syncthing

    • No modifications of the files are happening on the backup server. I need to read a execute the files.

Computer B (SEND ONLY): chmod -R 770 syncthing

    • Here, the files are modified and sent to the backup server. I need writing permissions.

In theory, this should work. If I am a part of syncthing group, then I have rwx permissions for all the files. In practice, LibreOffice says that access to these files was denied. Now I cannot work with the files that are beings synchrnonized.

If I change ownership of these files and let them belong to the another_user, then it all works. Another_user doesn’t have to belong to the syncthing group to modify the files.

Now I add syncthing to another_user group to be able to acess the files that the other user modifies.

Any insight would be appreciated.

The fact you added the user to the syncthing group doesn’t grant that group to every running process straight away.

Process groups are set when they are started, and are inherited from the parent process.

Namely, if your X server/desktop environment started before your user was part of that group, all processes launched from the desktop environment, including LibreOffice will start without knowing that your user is now a member of that group. You can verify this by running id in the shell, you’ll see that your identity is not aware of that group.

You can start a shell, run newgrp syncthing, which will spawn a subshell with that group now known, and you can launch applications from there.

Or just restart your desktop environment/machine to pick it up.

1 Like