content/blog/2022-10-04-syncthing.org

e8577d98faff1bed72ba6f2d204b8b44c6827c23
cleberg.net/content/blog/2022-10-04-syncthing.org rendered · source · history · blame · raw

180 lines · 7280 bytes

  1#+date:        <2022-10-04 Tue 00:00:00>
  2#+title:       Syncthing: Implementing Secure Peer-to-Peer Self-Hosted Cloud Storage
  3#+description: Technical instructions for setting up Syncthing as a peer-to-peer self-hosted file synchronization system that preserves data privacy by eliminating third-party intermediaries.
  4#+slug:        syncthing
  5#+filetags:    :syncthing:cloud-storage:privacy:
  6
  7* An Overview of Syncthing
  8
  9If you've been looking around the self-hosted cloud storage space for a
 10while, you've undoubtedly run into someone suggesting
 11[[https://syncthing.net][Syncthing]] as an option. However, it is an
 12unusual alternative for those users out there who are used to having a
 13centralized cloud server that serves as the "controller" of the data and
 14interacts with clients on devices to fetch files.
 15
 16This post is a walkthrough of the Syncthing software, how I set up my
 17personal storage, and some pros and cons of using the software.
 18
 19* Installing Syncthing
 20
 21To install Syncthing, visit the
 22[[https://syncthing.net/downloads/][Downloads]] page or install via your
 23device's package manager.
 24
 25** Server & Desktop
 26
 27You can install Syncthing on servers and desktops via the Downloads page
 28linked above or via the command-line.
 29
 30For Debian-based distros:
 31
 32#+begin_src sh
 33sudo apt install syncthing
 34#+end_src
 35
 36For Fedora-based distros:
 37
 38#+begin_src sh
 39sudo dnf install syncthing
 40#+end_src
 41
 42** Mobile
 43
 44Syncthing for Android is available on
 45[[https://f-droid.org/packages/com.nutomic.syncthingandroid/][F-Droid]]
 46and
 47[[https://play.google.com/store/apps/details?id=com.nutomic.syncthingandroid][Google
 48Play]]. Syncthing does not have an official iOS client, but there is a
 49third-party client called
 50[[https://apps.apple.com/us/app/m%C3%B6bius-sync/id1539203216][Möbius
 51Sync]].
 52
 53* How Does Syncthing Work?
 54
 55To start, I wanted to include the main marketing blurb from their
 56website:
 57
 58#+begin_quote
 59Syncthing is a continuous file synchronization program. It synchronizes
 60files between two or more computers in real time, safely protected from
 61prying eyes. Your data is your data alone, and you deserve to choose
 62where it is stored, whether it is shared with some third party, and how
 63it's transmitted over the internet.
 64#+end_quote
 65
 66Let's break this apart and add in some other details to help explain
 67what exactly Syncthing does in order to sync files between devices.
 68
 69** Local Syncthing Server(s)
 70
 71Syncthing syncs files between multiple devices by creating a local
 72server on each device. These local servers handle a few different
 73things, such as watching files and directories for changes, hosting an
 74administrative GUI website, and authenticating with connected devices.
 75
 76You can also start, stop, and restart the Syncthing server via the
 77command-line or web dashboard. If you're running Syncthing on a device
 78with =systemd=, you can use the following commands:
 79
 80#+begin_src sh
 81sudo systemctl start syncthing@username.service
 82sudo systemctl restart syncthing@username.service
 83sudo systemctl stop syncthing@username.service
 84#+end_src
 85
 86** Syncthing Dashboard
 87
 88This biggest part of Syncthing is the admin GUI website that runs on
 89each device (note that mobile devices will use the Syncthing app rather
 90than the web GUI). The admin GUI is available through the web browser on
 91the local device that is running Syncthing - simply go to
 92=http://localhost:8384= or =http://127.0.0.1:8384=. This web page is the
 93place where you will change settings, add/modify synced files, and
 94add/modify connected devices.
 95
 96Here's an example web GUI dashboard:
 97
 98#+caption: Syncthing Dashboard
 99[[https://img.cleberg.net/blog/20221020-syncthing/syncthing_gui.png]]
100
101** Remote Devices
102
103A cloud storage solution wouldn't be very useful if you aren't able to
104share data among various devices. Syncthing does this by sharing Device
105IDs to connect servers, and then by manually sharing Folders with
106devices that have been connected.
107
108For instance, if you have a laptop running Syncthing and then install
109the Syncthing mobile app on a phone, you could scan the laptop's QR code
110for Device ID and then accept the authentication on the laptop's
111dashboard. Next, you can use either device to select a folder for
112sharing and dictating which device should send, receive, or both.
113
114When you connect devices, you can set one device as an "Introducer,"
115which can add devices from the introducer to the device list, for
116mutually shared folders. You can also configure Auto Accept,
117compression, rate limits, and more settings per device.
118
119* My Personal Cloud Storage Set-up
120
121Personally, I use a model similar to a traditional cloud storage
122service. I have a "centralized" server running 24/7 that acts as an
123Introducer for my Syncthing network. I think of this as my main storage
124and all other devices as tertiary client devices. I will likely add
125additional servers as backups as time goes on so that I don't have to
126rely on my laptop or phone as the only backups.
127
128Currently, I have one desktop and one mobile device connected to the
129network, both running intermittently as they are not powered-on 24/7.
130
131The initial set-up of the software was easy enough, but data transfer
132rates were incredibly slow for me due to the Wi-Fi. Instead, I plugged
133my laptop into the ethernet network that my server is on and manually
134copied my folders over to the server with =scp=. Once complete,
135Syncthing validated that all files were there and not missing, and it
136did not need to transfer any data through the WAN.
137
138As slow as the transfer was going, this probably saved me a few days of
139waiting for my ~100GB sync.
140
141* Pros & Cons
142
143I've put together a short list of pros and cons for Syncthing. I thought
144about my experiences with Nextcloud, WebDAV, proprietary services
145(Google Drive, iCloud, etc.), and privacy-focused cloud solutions
146(pCloud, Tresorit, etc.).
147
148*Pros:*
149
150- I've faced no data loss at all through my two-month trial run.
151- No third-parties store your data on their servers.
152- You have full control over your data and can take your data and leave
153  at any time.
154- It's possible to encrypt client-side easily with software like
155  Cryptomator.
156- No proprietary clients or mounted volumes, just plain files and
157  folders.
158
159*Cons:*
160
161- The learning curve is steeper than traditional cloud services and is
162  focused on a technical audience.
163- If a device needs to modify files in a Folder, the devices will need
164  to sync ALL files from the folder, which may be large. To avoid size
165  restraints, split large folders into smaller folders for syncing.
166- Syncing can be slow due to the clients/servers initially connecting or
167  re-connecting after sleeping.
168- Multiple personal devices are required and require the user to own or
169  rent them as no third-party servers are involved in the storage of
170  data.
171
172Overall, I've had a great experience with Syncthing so far. I've had no
173data loss, syncing has been quick and easy when changes are made to
174files, device connections are reliable, and I love the freedom of
175controlling the clients and servers as I choose.
176
177Not to mention that I appreciate that I - or someone else - could pull
178the Syncthing [[https://github.com/syncthing][source code]] and continue
179development/support if the Syncthing Foundation decides to stop
180developing the software or sells the business.