Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Complete Cross-Platform Guide to Installing and Configuring Syncthing for Decentralized File Sync

Tech 1

Key Capabilities of Syncthing

Syncthing is a decentralized, peer-to-peer (P2P) file synchronization tool designed to keep files in sync across multiple devices without relying on third-party servers. Its core capabilities include:

  • Fully Open Source: Hosted on GitHub, Syncthing’s transparent codebase allows community audits and contributions, ensuring trust in its security.
  • Decentralized P2P Architecture: Data transfers occur directly between devices, eliminating central server bottlenecks and third-party data access risks.
  • Cross-Platform Compatibility: Supports Windows, macOS, Linux, BSD, Solaris, and Android, enabling sync across virtually any device ecosystem.
  • Enterprise-Grade Security: All data in transit uses TLS encryption, and each device authenticates via a unique, immutable device ID to block unauthorized access.
  • Real-Time Sync: Detects file modifications instantly and triggers sync operations within seconds, ensuring all devices have the latest version.
  • Version History Retention: Automatically preserves previous file versions, allowing recovery from accidental edits or deletions.
  • Flexible Configuration: Customize sync folders, bandwidth limits, sync schedules, and access permissions via an intuitive web interface.

Installation Guides

Windows Installation

  1. Download the latest Windows build from the official Syncthing website.
  2. Extract the ZIP archive to a permanent directory (e.g., C:\Tools\Syncthing).
  3. Double-click syncthing.exe to launch the application. A console window will open, and your default browser should automatically navigate to http://127.0.0.1:8384 (the web management UI).
  4. If the browser doesn’t auto-launch, manually enter the URL from the console. You’ll be prompted to opt in/out of anonymous usage data reporting—select your preferrence to proceed.
  5. Successful load of the web UI confirms installation completion.

Ubuntu Installation

  1. Upload the Linux AMD64 build to your Ubuntu server using SCP:
    scp syncthing-linux-amd64-v*.tar.gz ubuntu@your-server-ip:/home/ubuntu/
    
  2. SSH into your server and extract the archive:
    tar -zxf syncthing-linux-amd64-v*.tar.gz
    
  3. Optional: Rename the extracted folder for easier access:
    mv syncthing-linux-amd64-v* syncthing
    
  4. Navigate to the folder and start Syncthing:
    cd syncthing
    ./syncthing serve
    
  5. Enable Remote Web UI Access:
    • Stop the running service with Ctrl+C.
    • Restart with the GUI bound to all network interfaces:
      ./syncthing serve --gui-address=0.0.0.0:8384
      
    • Allow incoming traffic on port 8384 via UFW:
      sudo ufw allow 8384/tcp
      sudo ufw reload
      
    • Access the UI remotely at http://your-server-ip:8384.

Configuring Bidirectional File Sync

  1. Retrieve Device IDs:

    • On each device, open the Syncthing web UI, click the top-right Actions menu, and select "Show ID" to copy the unique device identifier.
  2. Link Devices:

    • On you're Windows machine, go to the "Devices" tab, click "Add Remote Device", paste the Ubuntu server’s ID, enter a friendly name (e.g., "Ubuntu Server"), and save.
    • Repeat this step on the Ubuntu server, adding the Windows device’s ID.
  3. Set Up Shared Folders:

    • On Windows, navigate to the "Folders" tab, click "Add Folder".
    • Enter a label (e.g., "Work Documents"), set the local path (e.g., C:\Work\SyncedDocs), and check the Ubuntu server under "Share With".
    • Enable versioning in the "Versioning" tab to retain old file versions, then save.
  4. Accept Sync on Ubuntu:

    • On the Ubuntu web UI, a notification will appear for the shared folder. Click "Accept".
    • Set the local path (e.g., /home/ubuntu/SyncedDocs), verify folder permissions allow read/write access, and enable sync to start bidirectional file transfers.

Setting Up Auto-Start

Windows Auto-Start

  1. Create a batch file (e.g., SyncthingAutoStart.bat) in your Syncthing directory with the following content:
    @echo off
    REM Launch Syncthing in hidden background mode
    if "%1"=="hidden" goto start_sync
    start /min mshta vbscript:CreateObject("WScript.Shell").Run("""%~dpn0""" hidden", 0)(window.close) & exit /b
    :start_sync
    cd /d "C:\Tools\Syncthing"  REM Replace with your Syncthing path
    start "" /b syncthing.exe serve --no-browser --no-restart --logflags=0
    
  2. Right-click the batch file and select "Create Shortcut".
  3. Press Win + R, type shell:startup, and press Enter to open the Startup folder.
  4. Move the shortcut to this folder—Syncthing will now launch automatically on login.

Ubuntu Auto-Start (Systemd Service)

  1. Create a systemd service file:
    sudo nano /etc/systemd/system/syncthing@.service
    
  2. Paste the following configurasion (replace /home/ubuntu/syncthing with your actual path):
    [Unit]
    Description=Continuous File Synchronization Service for User %I
    Documentation=https://syncthing.net/docs/
    After=network-online.target
    Wants=network-online.target
    
    [Service]
    User=%i
    WorkingDirectory=/home/%i/.config/syncthing
    ExecStart=/home/%i/syncthing/syncthing serve --no-browser --no-restart --logflags=0 --gui-address=0.0.0.0:8384
    Restart=on-failure
    RestartSec=5
    SuccessExitStatus=3 4
    RestartForceExitStatus=3 4
    
    # Security Hardening
    ProtectSystem=strict
    PrivateTmp=true
    ProtectHome=true
    NoNewPrivileges=true
    MemoryDenyWriteExecute=true
    SystemCallFilter=@system-service
    
    [Install]
    WantedBy=multi-user.target
    
  3. Save and exit (Ctrl+O, Enter, Ctrl+X), then reload systemd:
    sudo systemctl daemon-reload
    
  4. Enable and start the service (replace ubuntu with your username):
    sudo systemctl enable syncthing@ubuntu.service
    sudo systemctl start syncthing@ubuntu.service
    
  5. Manage the service with these commands:
    sudo systemctl restart syncthing@ubuntu.service  # Restart the service
    sudo systemctl stop syncthing@ubuntu.service     # Stop the service
    sudo systemctl status syncthing@ubuntu.service   # Check service status
    

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.