Skip to content

Instantly share code, notes, and snippets.

@txoof
Last active August 11, 2023 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save txoof/e120ecf8a92b0c29d988058c1bf04752 to your computer and use it in GitHub Desktop.
Save txoof/e120ecf8a92b0c29d988058c1bf04752 to your computer and use it in GitHub Desktop.
Set up Syncthing on Linux host for multiple users

Set Up SyncThing on Linux Host for Multiple Users

This covers setting up SyncThing on Ubunty/Debian

Install Syncthing

$ sudo apt-install syncthing

Enable Syncthing for Each User

Add a systemd file for each instance of syncthing.

sudo systemclt enable syncthing@alice
sudo systemctl enable syncting@bob

Start Syncthing for Each User

The ports must be configured manually. Starting the service will create all the necessary configuration files for the next step

sudo systemclt start syncthing@alice
sudo systemctl stop syncthing@alice
sudo systemctl start syncthing@bob
sudo systemctl stop syncthing@alice

Configure Syncthing For Each User

Set up each user's address ~/.config/syncthing/config.xml to match the following. Increment the port number (8384, 8385, 838n) for each user. Each user must have a unique port number. Use the address 0.0.0.0 to make the web gui accessible on the local network.

<gui enabled="true" tls="false" debugging="false">
    <address>0.0.0.0:8385</address>
    <apikey>abc123</apikey>
    <theme>default</theme>
</gui>

Set Up SyncThing on MacOS Host for Multiple Users

This covers setting up SyncThing for multiple users on MacOS

Install Syncthing

$ brew install syncthing

Enable syncthing for the current user by following the directions in homebrew.

Enable Syncthing for Each User

Copy /opt/Cellar/SyncThing/xx.yy.zz/homebrew.mxcl.syncthing.plist to ~/Library/LaunchAgents/homebrew.mxcl.syncthing.plist for each user.

Edit homebrew.mxcl.syncthing.plist and change the logging paths to /tmp/syncthing_username.log for each user

Configure Syncthing For Each User

Set up each user's address ~/Library/Application Support/Syncthing/config.xml to match the following. Increment the port number (8384, 8385, 838n) for each user. Each user must have a unique port number. Use the address 0.0.0.0 to make the web gui accessible on the local network.

<gui enabled="true" tls="false" debugging="false">
    <address>0.0.0.0:8385</address>
    <apikey>abc123</apikey>
    <theme>default</theme>
</gui>

As each user, load the homebrew.mxcl.syncthing.plist agent using launchctl load ~/Library/LaunchAgents/homebrew.mxcl.syncthing.plist

Configure syncthing as needed from the GUI by browsing to https://localhost:PORTNUMBER

@SamSirry
Copy link

I was trying to play with the service arguments to be able to specify the username and guiport along with the service name. I didn't succeed yet, but I'm sharing my attempt here.

The aim is to be able to do systemctl start syncthing@bob,3318
and inside the service file we have:

[Service]
Environment="SvcUser=cut -d',' -f1 %i"
Environment="SvcPort=cut -d',' -f2 %i"
User=$SvcUser
ExecStart=/usr/bin/syncthing serve --no-browser --no-restart --logflags=0 --gui-address=0.0.0.0:$SvcPort

Of course Environment= does not run the cut command.

Any ideas?

@txoof
Copy link
Author

txoof commented Jul 13, 2022

This post over at SuperUser appears to address this. There are a couple of different options, but I haven't tried them out yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment