GNU/Linux >> Linux Esercitazione >  >> Debian

Come installare Syncthing su desktop e server Debian

Questa guida spiega come installare e configurare Syncthing su Debian. Syncthing è un software libero di sincronizzazione file peer-to-peer, disponibile per Linux, BSD, macOS, Windows, Android e Solaris. I dati vengono scambiati direttamente tra i dispositivi, senza passare per un server centrale, e il traffico è protetto tramite TLS.

Installare Syncthing dal repository ufficiale

Importa la chiave GPG e aggiungi il repository ufficiale:

sudo apt-get install curl apt-transport-https
curl -s https://syncthing.net/release-key.txt | sudo apt-key add -
echo "deb https://apt.syncthing.net/ syncthing stable" | sudo tee /etc/apt/sources.list.d/syncthing.list
sudo apt-get update
sudo apt-get install syncthing

Avviare Syncthing come servizio systemd

Sostituisci username con il tuo nome utente:

sudo systemctl enable syncthing@username.service
sudo systemctl start syncthing@username.service
systemctl status syncthing@username.service

La configurazione viene creata in /home/username/.config/syncthing/, mentre la cartella predefinita di sincronizzazione è /home/username/Sync.

Aprire la porta del firewall

Syncthing usa la porta TCP 22000 per comunicare con i peer. Se usi UFW:

sudo ufw allow 22000/tcp

Accedere all’interfaccia web

Per impostazione predefinita, Syncthing ascolta su 127.0.0.1:8384. Apri il browser e visita:

https://127.0.0.1:8384

Se Syncthing è installato su un server remoto, puoi creare un tunnel SSH dal tuo computer locale:

ssh username@IP_DEL_SERVER -L 8384:127.0.0.1:8384

Poi apri https://127.0.0.1:8384 nel browser locale.

Configurare l’accesso remoto in modo sicuro

Esporre direttamente l’interfaccia di Syncthing su Internet non è consigliato. La soluzione migliore è usare un reverse proxy Nginx o Apache con HTTPS.

Nginx

sudo apt install nginx
sudo nano /etc/nginx/conf.d/syncthing.conf

Esempio di configurazione:

server {
  listen 80;
  server_name syncthing.example.com;

  location / {
    proxy_pass https://127.0.0.1:8384;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
  }
}

Verifica e ricarica Nginx:

sudo nginx -t
sudo systemctl reload nginx

Apache

sudo apt install apache2
sudo a2enmod proxy proxy_http headers
sudo nano /etc/apache2/sites-available/syncthing.conf

Esempio:

<VirtualHost *:80>
  ServerName syncthing.example.com
  ProxyPass / https://127.0.0.1:8384/
  ProxyPassReverse / https://127.0.0.1:8384/
  ErrorLog ${APACHE_LOG_DIR}/syncthing_error.log
  CustomLog ${APACHE_LOG_DIR}/syncthing_access.log combined
</VirtualHost>

Abilita il sito e riavvia Apache:

sudo a2ensite syncthing.conf
sudo systemctl restart apache2

Abilitare HTTPS con Let’s Encrypt

Installa Certbot:

sudo apt install certbot

Con Nginx:

sudo apt install python3-certbot-nginx
sudo certbot --nginx --agree-tos --redirect --hsts --staple-ocsp --email [email] -d syncthing.example.com

Con Apache:

sudo apt install python3-certbot-apache
sudo certbot --apache --agree-tos --redirect --hsts --staple-ocsp --email [email] -d syncthing.example.com

Aggiungere dispositivi e cartelle

Per collegare due dispositivi, apri Syncthing su entrambi. Nel primo dispositivo vai su Azioni > Mostra ID e copia l’ID. Nel secondo dispositivo scegli Aggiungi dispositivo remoto, incolla l’ID e salva. Conferma la richiesta di connessione anche sul primo dispositivo.

Per sincronizzare una cartella, premi Aggiungi cartella, scegli un’etichetta e un percorso. Nella scheda Condivisione seleziona il dispositivo remoto. L’utente Syncthing deve avere i permessi di scrittura sulla cartella.

Se necessario, puoi concedere i permessi con ACL:

sudo apt install acl
sudo setfacl -R -m u:username:rx /percorso/cartella/

Tipi di cartella

  • Invia e ricevi: modalità predefinita.
  • Solo invio: il dispositivo invia file ma non accetta modifiche dagli altri.
  • Solo ricezione: il dispositivo riceve file senza propagare modifiche agli altri.

Risoluzione dei problemi

Se due istanze non si collegano, verifica che la porta 22000 sia aperta e che Syncthing sia in ascolto:

sudo ss -lnpt | grep syncthing

Puoi anche modificare l’indirizzo di ascolto nel file ~/.config/syncthing/config.xml:

<listenAddress>tcp://0.0.0.0:22000</listenAddress>

Dopo la modifica, riavvia il servizio:

sudo systemctl restart syncthing@username.service
Debian
  1. Installare un server Minecraft su Debian 9

  2. Installare Redis Server su Debian 11

  3. Come installare MySQL 8.0 / 5.7 su Debian 11 / Debian 10

  4. Come Installare ProFTPD su Debian 8

  5. Come installare MySQL Server su Debian 9

Installare e configurare Syncthing su Ubuntu Desktop e Server

Installare FastPanel su Debian 11 in pochi comandi

Come installare I2P su server Debian

Come Installare GNOME Desktop su Debian 8

Configurare server VNC su Debian 10 Buster

Aggiungere il desktop GNOME a Debian 10 Buster