Skip to content

Instantly share code, notes, and snippets.

@pjobson
Last active June 25, 2024 01:49
Show Gist options
  • Save pjobson/c833bfc3b2f7f53db23486f94be9ab6f to your computer and use it in GitHub Desktop.
Save pjobson/c833bfc3b2f7f53db23486f94be9ab6f to your computer and use it in GitHub Desktop.
Syncthing Ubuntu/Mint Headless

Syncthing Ubuntu/Mint Headless

Syncthing: https://syncthing.net/

Syncthing is a free, open-source peer-to-peer file synchronization application available for Windows, Mac, Linux, Android, Solaris, Darwin, and BSD. It can sync files between devices on a local network, or between remote devices over the Internet. Data security and data safety are built into the design of the software.

This is written using Linux Mint 21.2 x86_64 using kernel 5.15.0-89-generic.

I couldn't find good directions for doing this, so here we go.

Install Syncthing

Add Repos

sudo curl -s https://syncthing.net/release-key.txt | sudo apt-key add -
sudo echo "deb https://apt.syncthing.net/ syncthing stable" | sudo tee /etc/apt/sources.list.d/syncthing.list

Install

sudo apt update
sudo apt install syncthing

Install apt-transport-https If Required

If you get the following error.

E: The method driver /usr/lib/apt/methods/https could not be found.
N: Is the package apt-transport-https installed?
E: Failed to fetch https://apt.syncthing.net/dists/syncthing/InRelease    

Install apt-transport-https

sudo apt install apt-transport-https

Syncthing User

Create User

I don't like to run services from my personal account, I also wanted the user's home directory in a non-standard path. Use whatever path you want or /home.

sudo useradd -r -M -d /raidarray/syncthing/ syncthing
sudo passwd syncthing

Login and Create Config

Login, I use su - you can use whatever.

sudo su - syncthing

Run syncthing.

syncthing

This will display a bunch of status info, just wait for a minute then do CTRL-C to force quit it. The goal here is to create the .config directory and files.

Exit back to your regular user.

exit

Disable Shell

I don't want syncthing to be able to login, so I change the shell to /bin/false.

sudo usermod --shell /bin/false syncthing

Edit the Config

I use vi you can use nano or whatever editor you like.

Here we are going to edit the syncthing user config file, you will need to change the pathing of course.

sudo vi /raidarray/syncthing/.local/state/syncthing/config.xml

Note they change this path now and then, you can find it with: find /raidarray/syncthing -type d -name syncthing

Look for:

<gui enabled="true" tls="false" debugging="false">
    <address>127.0.0.1:8384</address>

Change to:

<gui enabled="true" tls="false" debugging="false">
    <address>0.0.0.0:8384</address>

Save and quit.

Optionally Disable the Default Service

sudo systemctl stop [email protected]
sudo systemctl disable [email protected]
sudo rm /lib/systemd/system/[email protected]

Setup the Service

sudo cp /lib/systemd/system/[email protected] /lib/systemd/system/[email protected]
sudo systemctl enable [email protected]
sudo systemctl start [email protected]
sudo systemctl status [email protected]

This should output something like:

[email protected] - Syncthing - Open Source Continuous File Synchronization for syncthing
   Loaded: loaded (/lib/systemd/system/[email protected]; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2018-11-24 16:07:43 EST; 29min ago
     Docs: man:syncthing(1)
 Main PID: 22558 (syncthing)
   CGroup: /system.slice/system-syncthing.slice/[email protected]
           └─22558 /usr/bin/syncthing -no-browser -no-restart -logflags=0

Open Web GUI

You should be able to browse to your syncthing WebGUI now.

http://hostname:8384

Login with syncthing and whatever password you set.

@zloeber
Copy link

zloeber commented May 17, 2020

Thanks for this, worked first time with very little modifications required.

@Mirdarthos
Copy link

Thanks for this, worked first time with very little modifications required.

SAME.

Thank you!

@FirstMichal
Copy link

Thanks seems to work fine.

@StitchTech
Copy link

Seems to work great. Installed in a Ubuntu distro running on WSL 2.

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