Debian/Ubuntu 安装 Syncthing

通过 apt 安装最新版 Syncthing

相关文档

安装必要的 apt 工具(如果无)

1
2
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates

添加 apt.syncthing.net apt 源

下载 syncthing.net 公钥

1
2
sudo mkdir -p /etc/apt/keyrings
sudo curl -L -o /etc/apt/keyrings/syncthing-archive-keyring.gpg https://syncthing.net/release-key.gpg

添加 apt 源

1
echo "deb [signed-by=/etc/apt/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing stable" | sudo tee /etc/apt/sources.list.d/syncthing.list

安装 Syncthing

1
2
3
sudo apt-get update
sudo apt-get install syncthing/syncthing
syncthing --version
1
syncthing v1.29.2 "Gold Grasshopper" (go1.23.4 linux-amd64) [email protected] 2025-01-11 16:38:29 UTC [noupgrade]

使用 systemd 配置 Syncthing 服务

相关文档

新建一个用户(如果需要)

1
sudo adduser syncthinguser

启用并启动 Syncthing 服务

1
2
systemctl enable [email protected]
systemctl start [email protected]

然后就可以通过浏览器访问默认的 Web GUI 地址 http://127.0.0.1:8384 对 syncthing 进行配置和使用。

修改配置文件

如果不使用 Web GUI,可以手动修改配置文件。默认的配置文件位于 ~/.local/state/syncthing/,修改后重启 syncthing:

1
systemctl restart [email protected]

检查

通过 Cloudflare Tunnel 访问 Syncthing 的 Web GUI

因为懒得为 Syncthing 的 Web GUI 暴露公网端口、绑定域名、开启 https,使用 Cloudflare Tunnel 访问 Syncthing 的 Web GUI 是一个简单、安全的方法。

一般前提

要使用 Cloudflare Tunnel,一般需要:

  • 拥有一个 Cloudflare 账号。
  • 拥有一个可以绑定 Cloudflare 的域名。

创建、设置 tunnel

  1. 访问 Cloudflare One,转到 Networks > Tunnels 页面。

  2. 点击 “Create a tunnel” 创建一个新 tunnel, tunnel 类型选择 “cloudflared”。

  3. 为 tunnel 起一个名字。

  4. 选择自己服务器的系统和架构,复制页面上的代码到服务器中运行,即完成安装 “cloudflared”。

  5. 为 Web GUI 设置域名。URL 处填写 Syncthing Web GUI 的地址,例如 localhost:8384 (本地地址,不需要公网地址)。HTTP Host Header 填写localhost

  6. 保存 tunnel 即可。

  • 不要忘记为 Web GUI 设置密码。
  • 额外地,可以使用 Cloudflare Zero Trust(即 Access)进行进一步保护,例如在访问时要求 OTP 验证。

随后,即可以通过绑定的域名访问 Syncthing Web GUI。而无需配置 Web GUI 侦听公网地址、暴露公网端口、绑定域名。无需手动配置域名 dns 指向、无需手动配置 https。

Built with Hugo
Theme Stack designed by Jimmy