Syncing all the things
The core idea behind synchronization systems is essentially the same for all of them: given a list of directories and a list of systems, ensure that those directories have the same contents on each system. If a file is added on one, it is copied out to the rest; modifications and deletions are (usually) propagated as well. The trouble is always in the details, though; from fiddly setup procedures to data corruption and security problems, there are a lot of ways in which synchronization can go wrong. So users have to put a lot of trust in these systems; open source code is an important step toward that goal, but it is also necessary to believe that the developers involved have thought carefully through the issues.
Syncthing
![[Syncthing management screen]](https://static.lwn.net/images/2021/syncthing-sm.png)
The daemon is managed through an internal web server that shows up, by default, on port 8384; see the example image on the right. There is initially no authentication required; users will likely want to fix that as one of the first things they do. The web server is, by default, only accessible via the loopback interface; a change to a configuration file can make it available to the Internet as a whole, but that sounds like a daring thing to do even with authentication enabled. An alternative for gaining access to the web interface on a remote machine, as suggested in the documentation, is to set up an SSH tunnel from the local system.
When it starts for the first time, Syncthing generates a "device ID" identifying the local system; it looks like this:
RS5RZ7K-CORJAP3-TZECYOH-IBLFDZM-KSFWOXB-VBEIYSB-F7MWECH-VQCGLAZ
Setting up synchronization between two machines resembles the Bluetooth pairing process; it is done by providing each side with the device ID belonging to the other. Use of copy-and-paste is advisable here. Alternatively, if both systems are on the same local net, they will discover each other through broadcasts and ask (through the management interface) whether a connection should be established.
After a connection between systems is made, users must tell Syncthing which directories should be synchronized; that is a matter of setting up folders and sharing them with any or all of the known remote systems (which Syncthing calls "devices"). Once the share has been accepted on the remote end, file changes will be propagated back and forth. When possible, Syncthing requests file-change notifications from the kernel; that leads to relatively fast propagation times.
There are a lot of options that can be set to control sharing. Sharing can be made one-way, for example, so that a particular system might create files and send them out without accepting changes from the other systems. One especially interesting (though new and "beta") feature is the ability to share files to specific systems in encrypted form. If one system is, for example, a cloud server that is used primarily for backup or distribution purposes, it can be given encrypted data that it cannot read. Any other system in the sharing network that has the correct password will be able to read those files, though. There are also various ways of handling versioning, which keeps older versions of files around when one system changes them.
It's worth noting that, while it is possible to configure a set of Syncthing clients all connected to a central server, nothing in Syncthing requires that sort of architecture. Systems can be connected in any way that seems to make sense. If a system finds that it needs files that have already propagated to multiple connected peers, it can receive the needed data in blocks, BitTorrent-style, from whichever system can provide it first.
Discovery and security
Interestingly, neither host names nor IP addresses are involved in any stage of the configuration process — by default, at least; the systems find each other based only on the device ID regardless of which networks they are attached to. This, clearly, requires some third-party help. The Syncthing project runs a set of "discovery" servers that will help systems find each other based on their device IDs. There is also a set of "relay servers" that can relay data in situations where the systems involved cannot reach each other directly — when they are both behind NAT firewalls, for example.
Some thought has clearly gone into the security implications of this architecture. Data only goes through relay servers if there is no alternative, for example, and it is encrypted at the endpoints. But there is still some information that a hostile discovery or relay server could obtain that might worry some users. For anybody who is truly worried, the code for both types of server is available; anybody can set up private servers and configure their Syncthing instances to use only those.
According to the documentation, device IDs need not be kept secret, since an affirmative action is required on both sides to set up a connection. One might wonder whether an attacker might try to set up a system with a target's device ID and thus gain access to the managed files. That ID, though, is essentially a public key, and the connection process involves proving possession of the associated private key, so such an attack should not be possible. This page describes device IDs in more detail.
Syncthing on the move
Perhaps the most common use of synchronization on today's net is copying
photos from a phone handset to a central server. Since Android phones, at
least, are Linux-based, one need only set up a normal shell environment on
it and put Syncthing there to achieve this goal; the process shouldn't take
more than a day or so. Or one could just install
the Android app, which is available
on F-Droid and the Google Play Store as well. This app, shown on the
right, comes with a folder
for the camera (set for send-only sharing) configured out of the box, so it
is just a
matter of setting up the peers. And, lest one worry about typing one of
those device IDs with an on-screen keyboard, the app can read the QR code
that the web interface will helpfully provide, easing that process
considerably.
One slightly surprising behavior is that the app asks for location permission, which doesn't seem like something it would need. That permission is needed to determine which WiFi network (if any) the phone is on, which is useful for the feature configuring when synchronization should (and should not) be performed. Users of metered WiFi services may want to use this mechanism to avoid synchronization when it could cost them money. In the absence of this permission, the app will, by default, perform synchronization whenever it is connected to any WiFi network.
One need not look far to find complaints from users that the Android app drains the battery quickly. Your editor has not observed this behavior in a limited amount of testing; it is possible that the worst problems have already been fixed.
Closing thoughts
The project states that
"security is one of the primary project goals
", and the
developers do appear to have put some thought into the issue. Encryption
is used in the right places, certificates are verified, etc. A quick CVE
search turns up two entries over the last four years, one
of which enabled the overwriting of arbitrary files. Exploiting that
vulnerability would require first gaining control of one of the machines in
the sharing network, at which point the battle is likely lost anyway.
It does not seem that any sort of formal security audit has been
done, but the Syncthing developers are at least making the right kinds of
noises.
With regard to reliability, it is not hard to search for (and find) various scary stories from users who have lost data with Syncthing. It seems that many of those problems are the result of operator error; if you set up a system and allow it to delete all your data, it may eventually conclude that you want it to do exactly that. Synchronization can be amazingly efficient at propagating mistakes. Use of versioning can help, as can avoiding the use of two-way synchronization whenever possible. Syncthing doesn't seem like it has a lot of data-losing bugs, but backups are always a good idea.
Syncthing has been syncing things since at least 2013, when the first commit appears in its Git repository; LWN looked at it in 2014. The project is written mostly in Go, and is distributed under the Mozilla Public License. The current Syncthing release is 1.18.0; it came out on July 6 — while this article was being written. The project shows a nearly monthly release cadence in the last year; 1.7.0 was released on July 7, 2020. There have been 728 non-merge commits to the Syncthing repository over the last year from 40 developers; the top three developers (Simon Frei, Jakob Borg, and Jesse Lucas) account for just over 76% of of those commits. The project is thus not swarming with developers, but it appears healthy enough for now.
A company called Kastelo offers support subscriptions for Syncthing and provides significant resources for Syncthing development. The company also is part of the Syncthing Foundation which, in turn, manages the project's infrastructure and makes grants for development projects.
All told, Syncthing leaves a favorable impression. The developers seem to
have done the work to create a system that is capable, reliable, secure,
and which performs reasonably well. But they have also done the work to
make it all easy to set up and make use of — the place where a lot of
free-software projects seem to fall down. It is an appealing tool for
anybody wanting to take control of their data synchronization and
replication needs.
Posted Jul 9, 2021 15:34 UTC (Fri)
by smurf (subscriber, #17840)
[Link]
Figuring out why some device doesn't want to talk to some other device is a non-trivial process. That's hardly unique to synthing, though.
Posted Jul 9, 2021 19:16 UTC (Fri)
by Cyberax (✭ supporter ✭, #52523)
[Link]
Posted Jul 10, 2021 2:56 UTC (Sat)
by felixfix (subscriber, #242)
[Link]
Every once in a while, I marvel at how it works so smoothly that I almost forget it's running, and send a small contribution. I've thought once or twice of filing a bug report, that it doesn't have enough bugs to remind me of its existence, and they need to find that sweet spot of attracting just enough attention to garner more contributions.
Posted Jul 10, 2021 3:33 UTC (Sat)
by jkingweb (subscriber, #113039)
[Link]
Sadly the relatively involved initial setup scares off a lot of people I know. There's no good way around that, though.
Posted Jul 10, 2021 15:05 UTC (Sat)
by tau (subscriber, #79651)
[Link] (2 responses)
The issue is fully described in the links below but the gist of it (as I understand it, please correct me if I am wrong) is that recent versions of Android create separate isolated directories for each application on the device's external storage and do not allow access outside that directory using standard POSIX syscalls. If the application has a specific permission then an application can use a separate Java API to access the full external storage directory tree, but this presents integration difficulties for cross-platform applications.
The issue might also be limited to just Android 10, as the previous versions predate this policy and Android 11 supposedly has some mechanism that allows suitably privileged applications to restore POSIX access, but I am unable to verify that. If your device is stuck on Android 10 like mine is then you'll need to use a root backdoor with all the headaches that entails.
https://github.com/syncthing/syncthing-android/issues/29
Posted Jul 11, 2021 12:10 UTC (Sun)
by jkingweb (subscriber, #113039)
[Link] (1 responses)
Posted Jul 11, 2021 15:00 UTC (Sun)
by smurf (subscriber, #17840)
[Link]
Yes it's ugly, but so is "any random app can silently exfiltrate basically all of your personal data and images".
Posted Jul 10, 2021 20:51 UTC (Sat)
by bferrell (subscriber, #624)
[Link]
Posted Jul 10, 2021 23:30 UTC (Sat)
by tamara_schmitz (guest, #141258)
[Link]
Yeah about that user experience. If the devs want to reach little bigger audience it could use more UX improvements to present you such options that you actually need.
But I've been using Syncthing for 4 years, ran a relay at some point and have always been happy with it.
Posted Jul 11, 2021 4:37 UTC (Sun)
by alison (subscriber, #63752)
[Link]
Snort! I love LWN.
Posted Jul 12, 2021 11:49 UTC (Mon)
by jezuch (subscriber, #52988)
[Link] (3 responses)
Is there an easy way to set up such a server?
Posted Jul 12, 2021 18:13 UTC (Mon)
by smurf (subscriber, #17840)
[Link] (2 responses)
You ssh to the server (tunneling port 8384), install syncthing, start it, open its web interface, and copy the server key-
On the local device you add a new device (the cloud system). Then you create a shared folder andshare the folder with the cloud system (this step allows you to set a password).
On the cloud system you accept the shared folder.
Done.
Frankly IMHO this is all as intuitive as it gets.
Posted Jul 13, 2021 10:24 UTC (Tue)
by jezuch (subscriber, #52988)
[Link] (1 responses)
Posted Jul 24, 2021 14:08 UTC (Sat)
by vincent163 (guest, #153414)
[Link]
Posted Jul 16, 2021 23:17 UTC (Fri)
by dilinger (subscriber, #2867)
[Link] (4 responses)
Posted Jul 19, 2021 19:17 UTC (Mon)
by shane (subscriber, #3335)
[Link] (3 responses)
Posted Jul 21, 2021 18:25 UTC (Wed)
by dilinger (subscriber, #2867)
[Link] (2 responses)
Posted Jul 21, 2021 20:13 UTC (Wed)
by smurf (subscriber, #17840)
[Link] (1 responses)
Posted Aug 25, 2021 21:20 UTC (Wed)
by dilinger (subscriber, #2867)
[Link]
This is a regular thing, except usually just restarting the daemon either on my phone or my laptop will make it realize that it should sync. I've got Nextcloud up and running in an LXC container, just need to set it up on my phone. I sure hope it behaves more reliably than this!
Posted Jul 24, 2021 12:45 UTC (Sat)
by rolandog (subscriber, #151303)
[Link] (1 responses)
In order to do that, I:
- Set a folders in a device to "send only".
And that's it! I use it mainly to do some manual processing of the received photos and videos with Shotwell (*copying* and sorting my library into Year/Month/Day directories).
You may run into some issues where you may be promoted to "revert local additions" (I think on the receiver's end)... This mainly happens for two reasons:
- if you deleted a file on the receiver's "sync only once" folder
It is best to avoid the latter scenario; a quick fix for the first one is to make sure to delete the media first in the sender's device's folder and afterwards delete it on the receiver's device's folder.
After that, you can click "revert local additions", and the message should go away.
Posted Jul 24, 2021 23:01 UTC (Sat)
by monotux (guest, #130298)
[Link]
That was a very useful setting, thanks for taking the time to describe your workflow. I'm going to test a very similar setup on my phone as well.
Syncing all the things
Syncing all the things
Syncing all the things
Syncing all the things
Syncing all the things
https://forum.syncthing.net/t/android-11-all-files-access...
Syncing all the things
Syncing all the things
Syncing all the things
Syncing all the things
Syncing all the things
> environment on it and put Syncthing there to achieve this goal; the process shouldn't take > more than a day or so.
Syncing all the things
Syncing all the things
Syncing all the things
Syncing all the things
Syncing all the things
Syncing all the things
Syncing all the things
Syncing all the things
Syncing all the things
Syncing all the things
- Set a folder in a different device to "receive only".
- Set the "Ignore delete" advanced option for the desired folders on *both* devices.
- if you use a single folder where there may be other incoming files from other synced folders.
Syncing all the things