..

Syncthing on Android via Termux

Over the last few days, Syncthing’s community-driven Android port known as Syncthing-Fork underwent a strange change. The original developer’s GitHub repository for Syncthing-Fork now redirects to a new place, and it us unclear why or how the repository was handed over to another team. See this F-Droid blog post which links to this GitHub issue and this syncthing.net forum thread. While there doesn’t seem to be any malicious code in the new repository as I’m writing this, the circumstances behind this sudden shift in developer made some people, including myself, uneasy and led to be exploring an alternative.

It just so happens that Termux, everyone’s favorite Android terminal emulator app that effectively functions as its own Linux distribution of sorts, has a package for Syncthing. Now, the setup process isn’t exactly the most user-friendly. While the original (now discontinued) Syncthing Android port and subsequently Syncthing-Fork are definitely nicer wrappers that integrate better into the Android environment, this didn’t stop me from exploring this path.

While this blog post doesn’t serve as a full tutorial on how to set this up, I’ll go over a few things that I did to get this going from a high-level perspective:

  1. If you want Syncthing to be able to access your Android filesystem outside of your Termux environment (e.g. for access to the DCIM directory for photos), you’ll need to give it access to your shared storage, which can be done be following this guide. The long and short of it is that you need to run termux-shared-storage in the Termux terminal to trigger the permission request. You may need to revoke and re-grant the storage permission if you’re having issues. The root of shared storage will be accessible at ~/storage/shared and there are a few other directories that map to common Android directories such as ~/storage/dcim for camera photos. Note that this is optional if you don’t want Syncthing to touch your shared storage. I have my reasons for wanting this, you may have your reasons for not wanting this.
  2. Install Syncthing via pkg install syncthing
  3. Run syncthing in the Termux terminal emulator to have it create the needed files and open up a web browser into the Syncthing web interface. If you want access to the Syncthing web interface from another device like a PC, provided your Android device is connected to the same network, you can go to Actions->Settings->GUI and replace the IP of 127.0.0.1 in the GUI Listen Address with 0.0.0.0.
    • Note that this is optional and mostly for convenience. Please note the potential security risks of doing this. It will expose your device’s Syncthing web interface to your entire LAN. At the very least you may want to set a username and password on that same screen.
  4. Get Syncthing started on boot by installing Termux:Boot from F-Droid and creating a file at ~/.termux/boot/start-syncthing that contains something like this:
#!/data/data/com.termux/files/usr/bin/sh
termux-wake-lock
syncthing
  1. Reboot your device and you should now be able to access the Syncthing web interface on your Android device via your mobile web browser of choice (or on other device if you enabled this option)!.
  2. From there, when accessing the Syncthing web interface and adding shared folders, ensure that you use the path as it’s known to Termux. For example, if you are syncing a folder called Stuff, the path will look like this: /data/data/com.termux/files/home/storage/shared/Stuff (omit /storage/shared if you are not syncing to/from shared storage). As the web interface states, ~ can be used in place of /data/data/com.termux/files/home.

That’s about it!

While this setup is definitely not as simple as just installing an app, I’m going to roll with it for a while, hoping that this will be a safe and secure option. As with any Linux distribution, it all comes down to trusting the package maintainers to build and distribute safe, secure, and integrated software in the distribution’s repositories.

This site is powered by Hugo and the no style, please! theme.