在 Debian/Ubuntu 系统中安装和配置 Syncthing

本文介绍在 Debian/Ubuntu 系统上使用 apt 方式安装 Syncthing 的详细步骤,并涵盖相关配置和优化操作。

一、前言

Syncthing 是一款跨平台文件同步工具,官方提供多种安装方式,本文重点介绍通过 apt 方式进行安装的方法。文章源自堕落的鱼-https://www.duoluodeyu.com/2787.html

二、添加证书

首先,需要为系统添加 Syncthing 的官方证书,以确保软件包来源的可信度:文章源自堕落的鱼-https://www.duoluodeyu.com/2787.html

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

三、添加软件源

运行以下命令,将 Syncthing 官方源添加到系统的软件源列表:文章源自堕落的鱼-https://www.duoluodeyu.com/2787.html

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

更新软件包列表,并使用 apt 安装 Syncthing:文章源自堕落的鱼-https://www.duoluodeyu.com/2787.html

sudo apt-get update
sudo apt-get install syncthing

五、创建运行用户(可选)

出于安全考虑,不建议使用 root 账户运行 Syncthing。可以使用现有用户,或者创建一个新的 syncthing 用户:文章源自堕落的鱼-https://www.duoluodeyu.com/2787.html

adduser syncthing

六、运行 Syncthing

切换到 Syncthing 账户,并运行 Syncthing 以生成默认配置文件:文章源自堕落的鱼-https://www.duoluodeyu.com/2787.html

su syncthing
syncthing

首次运行后,程序会在 ~/.config/syncthing/ 目录下自动生成相关配置文件,随后可以手动关闭 Syncthing 进程。文章源自堕落的鱼-https://www.duoluodeyu.com/2787.html

七、更改 Web 管理页面监听 IP(可选)

如果希望远程访问 Syncthing 的 Web 管理页面,需要修改配置文件:文章源自堕落的鱼-https://www.duoluodeyu.com/2787.html

vi /home/syncthing/.local/state/syncthing/config.xml

找到如下字段:文章源自堕落的鱼-https://www.duoluodeyu.com/2787.html

<address>127.0.0.1:8384</address>

将其修改为:文章源自堕落的鱼-https://www.duoluodeyu.com/2787.html

<address>0.0.0.0:8384</address>

这将允许所有 IP 访问 Web 管理页面。如果仅需本机访问,则无需此步骤。

八、设置开机自动启动(可选)

使用 systemd 让 Syncthing 在系统启动时自动运行:

systemctl start [email protected]
systemctl enable [email protected]

九、访问 Syncthing 管理页面

在浏览器中输入以下地址,即可访问 Syncthing 的 Web 界面进行进一步配置:

http://<服务器IP>:8384

至此,Syncthing 已在 Debian/Ubuntu 系统上成功安装并配置,可用于安全、可靠的文件同步任务。

 
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证