Skip to content

Instantly share code, notes, and snippets.

@Jonny-exe
Last active April 17, 2024 08:15
Show Gist options
  • Star 19 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save Jonny-exe/9bad76c3adc6e916434005755ea70389 to your computer and use it in GitHub Desktop.
Save Jonny-exe/9bad76c3adc6e916434005755ea70389 to your computer and use it in GitHub Desktop.
syncthing setup exclusively with CLI

After long searching I did not find a good description of how to set up Syncthing that works exclusively via CLI without using a Web browser on the devices.

This is useful for example on a headless Raspberry Pi without proxying web-traffic through SSH or with port-forwarding limitations. In this example we will want to share the default folder from Machine A with Machine B

Machine A Machine B

Install Syncthing

On debian: sudo apt install syncthing

On fedora: sudo dnf install syncthing

Generate device ID and config files and default folder

syncthing generate

Start Syncthing

syncthing --no-browser

Get the device id

syncthing --device-id

Install Syncthing

On debian: sudo apt install syncthing

On fedora: sudo dnf install syncthing

Generate device ID and config files and default folder

syncthing generate

Start Syncthing

syncthing --no-browser

Get the device id

syncthing --device-id

Add Machine B

syncthing cli config devices add --device-id $DEVICE_ID_B

Add Machine A

syncthing cli config devices add --device-id $DEVICE_ID_A

Share default folder with Machine B

syncthing cli config folders $FOLDER_ID devices add --device-id $DEVICE_ID_B

Insert the id from the folder you want to share into $FOLDER_ID

Accept default folder from Machine A syncthing cli config devices $DEVICE_ID_A auto-accept-folders set true

If you don't want Machine B automatically accepting all of Machine A's folder requests, just run this command again with false

Additional useful info can be found at: https://superuser.com/questions/1397683/how-can-i-configure-syncthing-from-command-line-to-share-a-folder-with-another-c/1731999#1731999?s=0744928a5f9d4717b7445d039785ba53.

Don't waste your time with this repo, as it hasn't been updated since 2014, it is not working: https://github.com/classicsc/syncthingmanager

This repo https://github.com/tenox7/stc is useful but it doesn't not offer adding devices/folders.

@isoboroff
Copy link

In syncthing cli config folders $FOLDER_ID devices add $DEVICE_ID_B, this should actually be syncthing cli config folders $FOLDER_ID devices add --device-id $DEVICE_ID_B

@Jonny-exe
Copy link
Author

I just fixed it, thanks for telling me.

@combs
Copy link

combs commented Feb 14, 2023

Thank you for putting this together!

one snag,

$ syncthing generate
syncthing: error: unexpected argument generate
$ syncthing cli generate
No help topic for 'generate'

perhaps this step is no longer necessary? on my Ubuntu machine, I was able to start Syncthing v1.18.0-ds1 for the first time with just

# systemctl enable syncthing@MYUSERNAME
# systemctl start syncthing@MYUSERNAME

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