最初我尝试了官方的 TailScale配置:
#cloud-config
# The above header must generally appear on the first line of a cloud config
# file, but all other lines that begin with a # are optional comments.
runcmd:
# One-command install, from https://tailscale.com/download/
- ['sh', '-c', 'curl -fsSL https://tailscale.com/install.sh | sh']
# Set sysctl settings for IP forwarding (useful when configuring an exit node)
- ['sh', '-c', "echo 'net.ipv4.ip_forward = 1' | sudo tee -a /etc/sysctl.d/99-tailscale.conf && echo 'net.ipv6.conf.all.forwarding = 1' | sudo tee -a /etc/sysctl.d/99-tailscale.conf && sudo sysctl -p /etc/sysctl.d/99-tailscale.conf" ]
# Generate an auth key from your Admin console
# https://login.tailscale.com/admin/settings/keys
# and replace the placeholder below
- ['tailscale', 'up', '--authkey=tskey-abcdef1432341818']
# Optional: Include this line to make this node available over Tailscale SSH
- ['tailscale', 'set', '--ssh']
# Optional: Include this line to configure this machine as an exit node
- ['tailscale', 'set', '--advertise-exit-node']
Ubuntu 服务器安装完成并重新启动后,我无法在终端中找到 tailscale 程序。尽管 tailscale 在线管理控制台显示新节点确实已添加,但现在处于离线状态。
这里带有用户数据示例的链接非常有用,它在 Ubuntu Server 自动安装期间安装 TailScale:
#cloud-config
---
apt:
sources:
tailscale.list:
source: deb https://pkgs.tailscale.com/stable/ubuntu focal main
keyid: 2596A99EAAB33821893C0A79458CA832957F5868
packages:
- tailscale
runcmd:
- [tailscale, up, -authkey, ${tailscale_key}]
安装 Ubuntu 并重启系统后,我能够在系统上找到 TailScale 程序。但身份验证部分:
runcmd:
- [tailscale, up, -authkey, ${tailscale_key}]
不工作,并且 TailScale 状态为登出。
我尝试了其他几种方法来解决这个问题,但都没有成功:
runcmd:
- [tailscale, up, -authkey, tskey-client-ffffffff, --advertise-tags=tag: server, --advertise-exit-node, --ssh, --operator=oleh]
late-commands:
- sudo curtin in-target --target=/target -- /usr/bin/tailscale up -authkey tskey-client-ggggggg # --advertise-tags=tag:server --advertise-exit-node --ssh --operator=oleh
还尝试将登录命令添加到 crontab 和 systemd。
问题是,如何在自动安装期间或首次重启后登录 TailScale?