Syncthing - secure file synchronisation

The problem…

I recently started to use Emacs’s org-mode for a few different workflows, journaling, blogging organising my schedule and task lists etc. That is a blog post in and of itself but the main thing to know is org-mode uses plain text files to store everything. When I’m at my computer this is great, I can add journal entries or check things off my todo list and everything works. :)

Things like a shopping list don’t work as well. I want to mark items I’ve collected whilst I’m doing my shopping. Short of bringing my laptop and Emacs with me to the supermarket, this wasn’t something I could do.

After a little googling / duckduckgo-ing I stumbled onto a small org-mode client for Android called Orgzly. This allowed me to look at my org agenda and work with lists while on my phone. Great! However there was one last piece of the puzzle remaining.

How do I keep my plain text .org files, with my TODO lists and agenda, synchronised between my laptop and my phone?

Enter Syncthing.

What is Syncthing?

Syncthing is a continuous file synchronisation program. It is an Open Source and Secure tool for keeping files synchronised between multiple computers. It is also super easy to use.

I use Syncthing to keep my todo lists and org agenda files in sycn between my computer and my mobile phone. The synchronisation is two way and Syncthing gives you a lot of control regarding who, how, when and what to sync. I’ve set up both my computer and phone to check once per hour if any of the synced files have changed.

So far this has worked really well for me.

About the Project

The team behind Syncthing list three main objectives Syncthing tries to fufil while keeping your files in sycn:

Private and Secure

  • Private - Only you decide where your data is stored
  • Encrypted - TLS all the way down
  • Authenticated - Explicit controlls about who can access what

Open

Easy to use

  • Portable - corss operating systems support
  • Powerful - Sync many folders between many devices and even many people
  • Simple - Syncthing has an easy to use web UI

It synchronises files between two or more computers in real time, safely protected from prying eyes. Your data is your data alone and you deserve to choose where it is stored, whether it is shared with some third party, and how it’s transmitted over the internet.

How to install it

Installing it is really simple.

On OSX I believe you only need to do a brew install. On a Debian flavour Linux bistro you can to an apt install from the Debian package repository. Specifc instructions for that can be fouund here. :)

That link walks you through adding the syncthing apt repository and prioratising it over the default distribution repositories.

Once you’ve done that, it is a simple apt install:

sudo apt-get update
sudo apt-get install syncthing

Syncing some files!

Now Syncthing is installed, we are ready to sync some files! We’re going to need another device with Syncthing installed for this to work. I use the Syncthing Android app on my phone.

Start Syncthing on your computer:

syncthing

Then navigate to the admin panel in a browser. For me the admin panel runs at http://127.0.0.1:8384/. The first thing you’ll want to do is add a new device. There is a helpful button for that on the bottom right hand side of the GUI. That will open a menue which allows you to either manually enter the device ID of your phone or better yet there is a Show QR button which will let your phone scan the device ID from your computer.

Figure 1: Syncthing Web UI

Figure 1: Syncthing Web UI

Once you’ve added the Device ID form one device to the other, you may be get a prompt saying device x (your phone) wants to connect. Do you want to allow it? Double check the device ID matches your phone and select yes. If you don’t recive the prompt then you’ll need to enter the device ID by hand, this is a little tedious but you only need to do it once. You need to explicitly allow devices to share between themselves, if someone else tries to connect to your device you can decline them.

Cool! We now have two devices that can talk to each other. Lets share some files.

At the top left on the web UI is the foldrs section. You may have a default folder there already but it wont be shared yet. Lets add a new folder to share. Click on, Add Folder and you’ll be greated with a modal. Give your shared folder a label and then click on the Sharing tab. Here you can choose which devices you want to share this folder with. Select your phone and then click on Save. On your phone you should recive a notification that your computer wants to share a new folder with you! Accept this folder and provide a path for where you wnat the folder to live on your phone.

Now on your phone shold start pulling down all the files inside the sahred folder! Yay! Futhermore any changes made on the phone will be synced back into the computer.

For a more granular and comprehensive walk-through check the official docs. :-)

A note about versioning

Syncthing provides a few options for versioning files, when the same file changes on both devices between syncing. Currently I’ve not had this problem because I don’t tend to use the two devices simultaneously. I’m sure I’ll eventually have a snag though so I’d advise you to keep your shared files under some form of version control just in case things go wrong. :/ F’s

Running as a systemd service

I don’t want to think about starting Syncthing everytime I start my machine! Finally, I want Syncthing to run whenever I login to my computer. The Syncthing docs have a how-to about this covering several options. I went with systemd. The Unbuntu package already has the systemd service installed I just needed to enable it like so:

systemctl --user enable syncthing.service
systemctl --user start syncthing.service

systemctl --user status syncthing.service

Conclusion

So that is my very brief take on Syncthing. I’ve found it really useful and I’d wholeheartedly recomend it to anyone who want to keep files in sync between their phone and computer or even multiple computers.

Syncthing is, open, secure and easy to use so why not check it out?

Thanks for reading. :)