Skip to content

Getting Started

jpjp edited this page Jan 6, 2014 · 24 revisions

Here's how to get started with syncthing on Linux.

syncthing will synchronise a single directory between a cluster of nodes that you configure. Each node will have its own unique ID. Only nodes with an ID listed in the config file are allowed to connect.

First make sure go is installed, using something like:

$ sudo apt-get install golang   # Debian/Ubuntu
$ sudo yum install golang       # Fedora/RHEL

Download syncthing from https://github.com/calmh/syncthing/releases and unpack it

$ tar zxvf syncthing-linux-*tar.gz

Check out the options:

$ syncthing --help
Usage:
  syncthing [options]
...

Run syncthing on the first node to let it create it's config directory and certificate:

$ syncthing
19:54:18 INFO: Version v0.3.1
19:54:19 OK: Created TLS certificate file
19:54:19 OK: Created TLS key file
19:54:19 INFO: My ID: NCTBZAAHXR6ZZP3D7SL3DLYFFQERMW4Q
19:54:19 FATAL: No config file

Take note of the "My ID: ..." line.

Now do the same for the second node, again taking note of the "My ID: ..." line.

You can now create your config file under

~/.syncthing/syncthing.ini

and this file should be the same on all nodes. It will look something like this:

[repository]
dir = /Users/jb/Synced

[nodes]
NCTBZAAHXR6ZZP3D7SL3DLYFFQERMW4Q = 172.16.32.1:22000 192.23.34.56:22000
CUGAE43Y5N64CRJU26YFH6MTWPSBLSUL = dynamic

This assumes that the first node is reachable on either of the two addresses listed (perhaps one internal and one port-forwarded external) and that the other node is not normally reachable from the outside.

If the nodes are running on the same network, or reachable on port 22000 from the outside world, you can set all addresses to "dynamic" and they will find each other using automatic discovery. (This discovery, including port numbers, can be tweaked or disabled using command line options.)

Start syncthing on both nodes. For the cautious, one side can be set to be read only.

$ syncthing --ro
20:07:20 INFO: Version v0.3.1
20:07:21 INFO: My ID: NCTBZAAHXR6ZZP3D7SL3DLYFFQERMW4Q
20:07:21 INFO: Loading index cache
20:07:21 INFO: Populating repository index
20:07:21 INFO: Listening for incoming connections
20:07:21 INFO: Attempting to connect to other nodes
20:07:21 INFO: Sending local discovery announcements
20:07:21 INFO: Sending external discovery announcements
20:07:37 INFO: Connected to node CUGAE43Y5N64CRJU26YFH6MTWPSBLSUL
20:07:37 INFO: Sent initial index to node CUGAE43Y5N64CRJU26YFH6MTWPSBLSUL
20:08:21 INFO:      4 files, 100.00 MiB in cluster
20:08:21 INFO:      4 files, 101.36 MiB in local repo
20:08:21 INFO:      1 files,        0 B in to synchronize
...

You should see the synchronization start and then finish a short while later. Add nodes to taste.