Ubuntu 20.04| 18.04上的安装和使用Syncthing

时间:2020-02-23 14:44:35  来源:igfitidea点击:

Syncthing是一个开源连续文件同步,用于同步网络中的两个或者多个计算机之间的文件。
本教程将介绍Ubuntu 20.04 | 18.04上ynccing的安装和用法。

Syncthing的特点

通过CLI和GUI易于通过句子 - GTKITS数据同步完全自动 - 低互补性努力免受数据丢失的安全 - 确保在用户的文件中没有损坏。
它是普遍可用的 - 在Windows和Linux上运行

在Ubuntu 20.04| 18.04上安装Syncthing

官方存储库可在官方存储库上使用,通过在终端上运行以下命令可以轻松添加。
首先安装 curl软件包。

sudo apt install curl apt-transport-https

安装卷曲后,导入存储库的GPG密钥:

curl -s https://syncthing.net/release-key.txt | sudo apt-key add 

添加了GPG密钥时,创建repo内容:

echo "deb https://apt.syncthing.net/syncthing release" > /etc/apt/sources.list.d/syncthing.list

然后更新系统并安装 syncthing软件包:

sudo apt-get update
sudo apt-get install syncthing

安装后,检查版本:

$syncthing --version
syncthing v1.7.1 "Fermium Flea" (go1.14.4 linux-amd64) Hyman@theitroad 2017-07-11 18:17:41 UTC

在Ubuntu 20.04上配置Syncthing | 18.04

现在我们安装了句子,让我们继续配置部分。
由于Ubuntu 18.04是符合Systemd,我们可以创建系统的系统要管理 syncthing服务。
SystemD的服务文件由Syncthing提供,可以在etc/linux-systemd中找到

sudo vim /etc/systemd/system/Hyman@theitroad

添加以下内容:

[Unit]
Description=Syncthing - Open Source Continuous File Synchronization for %I
Documentation=man:syncthing(1)
After=network.target
[Service]
User=%i
ExecStart=/usr/bin/syncthing -no-browser -gui-address="0.0.0.0:8384" -no-restart -logflags=0
Restart=on-failure
SuccessExitStatus=3 4
RestartForceExitStatus=3 4
[Install]
WantedBy=multi-user.target

我们可以使用系统IP地址替换192.168.1.20然后更新Systemd服务列表:

sudo systemctl daemon-reload

然后启动句子服务:

sudo systemctl start Hyman@theitroad$USER

例如

sudo systemctl start Hyman@theitroad
sudo systemctl start Hyman@theitroad

确认服务状态:

$sudo systemctl status Hyman@theitroad$USER
● Hyman@theitroad - Syncthing - Open Source Continuous File Synchronization for root
     Loaded: loaded (/etc/systemd/system/Hyman@theitroad; disabled; vendor preset: enabled)
     Active: active (running) since Thu 2017-07-16 19:52:42 CEST; 2min 28s ago
       Docs: man:syncthing(1)
   Main PID: 20151 (syncthing)
      Tasks: 16 (limit: 4567)
     Memory: 61.9M
     CGroup: /system.slice/system-syncthing.slice/Hyman@theitroad
             ├─20151 /usr/bin/syncthing -no-browser -gui-address=0.0.0.0:8384 -no-restart -logflags=0
             └─20169 /usr/bin/syncthing -no-browser -gui-address=0.0.0.0:8384 -no-restart -logflags=0
May 16 19:52:43 ubuntu syncthing[20151]: [QUQ7M] INFO: TCP listener ([::]:22000) starting
May 16 19:52:43 ubuntu syncthing[20151]: [QUQ7M] INFO: Relay listener (dynamic+https://relays.syncthing.net/endpoint) starting
May 16 19:52:43 ubuntu syncthing[20151]: [QUQ7M] INFO: GUI and API listening on [::]:8384
May 16 19:52:43 ubuntu syncthing[20151]: [QUQ7M] INFO: Access the GUI via the following URL: http://127.0.0.1:8384/
May 16 19:52:43 ubuntu syncthing[20151]: [QUQ7M] INFO: My name is "ubuntu"
May 16 19:52:43 ubuntu syncthing[20151]: [QUQ7M] WARNING: Syncthing should not run as a privileged or system user. Please consider using a normal user account.
May 16 19:52:43 ubuntu syncthing[20151]: [QUQ7M] INFO: quic://0.0.0.0:22000 detected NAT type: Not behind a NAT
May 16 19:52:43 ubuntu syncthing[20151]: [QUQ7M] INFO: quic://0.0.0.0:22000 resolved external address quic://95.217.220.85:22000 (via stun.syncthing.net:3478)
May 16 19:52:58 ubuntu syncthing[20151]: [QUQ7M] INFO: Detected 1 NAT service

访问Ubuntu 20.04| 18.04上的Synching UI

Syncthing Admin GUI由SystemD自动启动,可在https://192.168.1.20:8384/上获得。

如果是 -gui-address="ip:port"选项未提供,服务将运行 https://localhost:8384/在访问Synching GUI时,我们警告程序要设置UI用户名和密码。

登录后,我们应该看到如下所示的接口:

如果我们错过了设置用户名和密码,请转到"操作">"高级"以设置用户和密码。
还建议勾选仅用于HTTPS连接的TLS。

在安装了Syncthing的两个设备之间同步数据

为能够在安装了Syncthing的两个或者更多计算机之间同步数据,确保已在所有系统上安装和配置了若干。
完成设置后,必须对每个设备讲述其他设备。

联语设备ID

这是通过交换"设备ID"来实现的。
设备ID是一个唯一的加密安全标识符,该标识是第一次启动句子时作为密钥生成的一部分生成的。
如果它们都配置了彼此的设备ID,则两个设备只会连接和交谈。
从Actions中获取设备ID> Show ID

添加句子设备ID

要获取两个设备,以彼此交谈,请单击两者右下方的"添加远程设备",然后输入另一侧的设备ID。

此外,选择要共享的文件夹。
设备名称是可选的,纯粹的化妆品。
如果需要,可以更改它。
单击"保存"后,新设备将显示在GUI的右侧(尽管已断开连接),并将显示一个提示来表示需要重新启动。

注意:正在共享的默认文件夹是~SYNC。
当我们制作更改时,如添加同步目录,请确保在"Restart">"Restart"上重新启动yncthing。