Full Guide: Migrating ZeroTier Controller, ztncui and Data to a New Host
Introduction
ZeroTier-One is an innovative open-source networking software. Its advanced capabilities allow seamless connectivity across devices, irrespective of physical location, providing organizations with scalable and fortified network solutions. Complementing this software, ztncui serves as the web-based user interface, simplifying network management and offering comprehensive insights into ZeroTier networks.
Within this guide, I explain the precise procedure for migrating the ZeroTier-One controller and ztncui data from a "Donor Host" to a "Recipient Host." The term "Donor Host" refers to the original system hosting the current ZeroTier-One controller and ztncui. The term "Recipient Host" designates the destination system where we aim to transfer the controller and ztncui data, guaranteeing an uninterrupted continuation of network operations.
I created this step-by-step manual in response to a noticeable lack of decent resources online, which frequently provide inaccurate or misleading information. Its main goal is to equip system administrators with the knowledge and assurance needed to carry out successful migrations.
Please bear in mind that this guide is specifically designed for sysadmins using Debian or Debian-based distributions. It's important to note that the ztncui is installed from a DEB package, not as a Docker container. For RPM-based systems, the process will be nearly identical. I will assume you are familiar with the necessary procedures.
I hope that this guide will be very helpful to anyone who wants clear and reliable documentation of a process.
Donor Host
Step 1 : Stop the services:
sudo systemctl stop ztncui
sudo systemctl stop zerotier-one
Step 2 : Copy the Data:
sudo cp -a /opt/key-networks/ztncui/etc /path/to/backup_location
sudo cp -a /var/lib/zerotier-one /path/to/backup_location
Recipient Host
Step 1 : Install ZeroTier-One Controller and ztncui:
Step 2 : Stop ZeroTier Controller and zerotier-one on the Recipient Host:
sudo systemctl stop ztncui
sudo systemctl stop zerotier-one
Step 3 : Copy the Data from the Donor to the Recipient:
rsync -rva user@donor_host:/path/to/backup_location/etc /opt/key-networks/ztncui/
rsync -rva user@donor_host:/path/to/backup_location/zerotier-one /var/lib/
Step 4 : Set Proper Ownership:
ls -l /opt/key-networks/ztncui/etc
-rw------- 1 ztncui ztncui 148 Jul 26 09:48 default.passw
-rw------- 1 ztncui ztncui 435 Jul 26 09:48 passwd
drwxr-xr-x 2 ztncui ztncui 4096 Jul 26 09:48 storage
drwxr-x--- 2 ztncui ztncui 4096 Jul 26 09:48 tlsd
ls -l /var/lib/zerotier-one
-rw------- 1 zerotier-one zerotier-one 24 Jul 26 09:54 authtoken.secre
drwx------ 4 zerotier-one zerotier-one 4096 Jul 26 09:54 controller.d
-rw-r--r-- 1 zerotier-one zerotier-one 141 Jul 26 09:54 identity.public
-rw------- 1 zerotier-one zerotier-one 270 Jul 26 09:54 identity.secret
drwxr-xr-x 2 zerotier-one zerotier-one 4096 Jul 26 09:54 networks.d
drwxr-xr-x 2 zerotier-one zerotier-one 4096 Jul 27 12:22 peers.d
-rw-r--r-- 1 zerotier-one zerotier-one 570 Jul 26 09:54 planet
-rwxr-xr-x 1 zerotier-one zerotier-one 10892304 Jul 26 09:54 zerotier-cli
-rwxr-xr-x 1 zerotier-one zerotier-one 10892304 Jul 26 09:54 zerotier-idtool
-rwxr-xr-x 1 zerotier-one zerotier-one 10892304 Jul 26 09:54 zerotier-one
-rw-r--r-- 1 zerotier-one zerotier-one 4 Jul 26 09:58 zerotier-one.pid
-rw-r--r-- 1 zerotier-one zerotier-one 4 Jul 26 09:58 zerotier-one.port
-rw-r--r-- 1 zerotier-one zerotier-one 276 Jul 26 09:54 zerotier-one.te
Recommended by LinkedIn
sudo chown -R ztncui:ztncui /opt/key-networks/ztncui/etc
sudo chown -R zerotier-one:zerotier-one /var/lib/zerotier-one
Step 5 : Generate New Secret and Set Access Privileges:
sudo sh -c "echo ZT_TOKEN=$(sudo cat /var/lib/zerotier-one/authtoken.secret) > /opt/key-networks/ztncui/.env"
sudo sh -c "echo HTTPS_PORT=3443 >> /opt/key-networks/ztncui/.env"
sudo sh -c "echo NODE_ENV=production >> /opt/key-networks/ztncui/.env"
sudo chmod 400 /opt/key-networks/ztncui/.env
sudo chown ztncui:ztncui /opt/key-networks/ztncui/.env
Step 6 : Add Host IP to Access Web UI:
sudo nano /opt/key-networks/ztncui/.env
HTTPS_HOST=<your-receipment-ip-address>
Step 7 : Restart Controller UI (ztncui) and zerotier-one:
sudo systemctl start ztncui
sudo systemctl start zerotier-one
Step 8 : Verify the Migration:
sudo systemctl status ztncui
sudo systemctl status zerotier-one
sudo journalctl -u ztncui -u zerotier-one -f
After Successful Migration
Step 1 : Verify the Recipient Host:
Step 2 : Disable ZeroTier Processes on the Donor Host:
sudo systemctl stop ztncui
sudo systemctl stop zerotier-one
sudo systemctl disable ztncui
sudo systemctl disable zerotier-one
Step 3 : Optionally, Remove Old ZeroTier-One Data on the Donor Host:
sudo rm -rf /var/lib/zerotier-one
sudo systemctl enable --now zerotier-one
If you start a new identity of ZeroTier-One on the donor host, it will function as a separate and isolated controller from the one on the recipient host.
Congratulations! You have successfully migrated the ZeroTier-One controller identity and the ztncui data to the Recipient host. The services should now be accessible through the web interface, and your ZeroTier networks should be fully operational on the new host. Remember to double-check and verify all steps in the migration process before making any changes. Regularly back up critical data and configurations to ensure smooth transitions and avoid data loss during the migration process.
This guide is published under the Creative Commons Attribution-ShareAlike 4.0 International License (CC BY-SA 4.0).
Zerotier GitHub: https://github.com/zerotier/ZeroTierOne ztncui GitHub: https://github.com/key-networks/ztncui