PengyOS / Docs / Recipes / Syncthing

Syncthing

Syncthing keeps folders in sync between your machines, peer to peer, with no cloud in between. It's a single static program, so it runs from your home directory as a user service.

ServerDesktop

Desktop, the easy way: the COSMIC Store has SyncThingy (Syncthing plus a tray icon), Syncthing Tray and Syncthing GTK on Flathub. Install one and skip the rest of this page. The steps below suit a Server, or a Desktop where you want Syncthing running before anyone logs in.

Install

mkdir -p ~/.local/bin
V=$(curl -fsSL https://api.github.com/repos/syncthing/syncthing/releases/latest | jq -r .tag_name)
curl -fsSL "https://github.com/syncthing/syncthing/releases/download/$V/syncthing-linux-amd64-$V.tar.gz" \
  | gzip -dc | tar -xf - -C /tmp
install -m 755 /tmp/syncthing-linux-amd64-$V/syncthing ~/.local/bin/
syncthing --version

Run it as a service

Syncthing ships a systemd user unit. Use it, pointed at your copy of the program:

mkdir -p ~/.config/systemd/user
sed 's|/usr/bin/syncthing|%h/.local/bin/syncthing|' \
  /tmp/syncthing-linux-amd64-$V/etc/linux-systemd/user/syncthing.service \
  > ~/.config/systemd/user/syncthing.service

sudo loginctl enable-linger "$USER"     # run at boot, not only while you're logged in
systemctl --user daemon-reload
systemctl --user enable --now syncthing.service
systemctl --user status syncthing.service

Its configuration and keys live in ~/.local/state/syncthing.

Open the web UI

The UI listens on 127.0.0.1:8384, on this machine only.

The first time, the UI asks you to set a username and password. Do it. Then add the other device by its ID. This machine's ID is shown under Actions → Show ID, or:

syncthing cli show system | jq -r .myID

Let other devices connect

Syncthing works through the firewall without changes: it connects out, and it falls back to relays. Direct connections from your LAN are faster, though. To allow them, add these to the input chain of /etc/nftables.conf (how):

        tcp dport 22000 ct state new accept      # sync (TCP)
        udp dport 22000 accept                   # sync (QUIC)
        udp dport 21027 accept                   # LAN discovery
sudo nft -c -f /etc/nftables.conf && sudo systemctl restart nftables

Upgrade

Run the install step again, then systemctl --user restart syncthing.

← llama.cpprclone →