在 macOS 上通过 OrbStack 虚拟机使用 Tailscale
Using Tailscale with an OrbStack VM on macOS

原始链接: https://github.com/highpost/tailscale-macos-vm

本仓库提供了一种在 macOS 上使用 OrbStack 快速配置 Ubuntu 虚拟机并将其无缝接入 Tailscale 网络的工作流。得益于 OrbStack 的原生 Linux 内核,Tailscale 可以完全访问内核网络功能,从而避免了用户空间(userspace)方案的局限性。 设置流程包括: * **配置:** 通过 `dev-server.yml` 使用 `cloud-init` 来定义环境及自动化任务。 * **安全性:** 采用 macOS 特有方式,将 Tailscale 身份验证密钥安全存储于 Apple 钥匙串(Keychain)中,并在虚拟机启动时注入。 * **Tailscale 集成:** 为 “myservers” 标签配置访问控制列表(ACL),以实现无缝的 Tailscale SSH 访问。 提供的脚本实现了全生命周期的自动化:`build.sh` 用于环境配置,`run.sh` 负责身份验证与 Tailscale 启动,`cleanup.sh` 确保彻底清理。系统运行后,用户无需暴露主机端口即可通过 Tailscale SSH 或 MagicDNS 直接连接虚拟机,甚至支持通过 Tailscale 网络执行 `git clone` 等远程操作。该方案提供了一个稳健、安全且易于销毁的开发环境,并能完全集成到您的私有网络中。

Hacker News 最新 | 往日 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 在 macOS 上使用 OrbStack 虚拟机运行 Tailscale (github.com/highpost) 5 分,作者:highpost,2 小时前 | 隐藏 | 往日 | 收藏 | 讨论 | 帮助 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索:
相关文章

原文

This repository demonstrates how to use OrbStack on macOS to provision an Ubuntu virtual machine (VM), and then add it to your tailnet.

Unlike minimal container runtimes that lack native kernel modules, OrbStack provides a fully capable Linux kernel environment. This allows Tailscale to leverage standard kernel networking (/dev/net/tun) rather than relying on userspace-networking workarounds.

OrbStack first spins up a temporary VM instance which allows cloud-init to pull its configuration from dev-server.yml and then stops the VM. Then OrbStack wakes up the pre-configured VM, adds it to your tailnet using an auth key and enables Tailscale SSH. You can then SSH to your VM from anywhere, without exposing host ports.

This example also demonstrates a macOS-specific method for securely storing your Tailscale auth key in Apple Keychain. Due to macOS security sandbox restrictions, the guest VM cannot directly execute security find-generic-password to pull secrets from the host. Instead, the credential must be injected from the host macOS environment during provisioning, as shown in run.sh.

Before launching the VM, configure your Tailscale Access Control Lists (ACLs) to handle the automated registration and permissions.

Go to Access controls > Tags and define a server tag:

Modify the Tailscale SSH access controls

Go to Access controls > Tailscale SSH and ensure your policy permits access to the tagged servers and specified users:

{
  "action": "accept",
  "src": ["autogroup:admin"],
  "dst": ["tag:myservers"],
  "users": ["player1", "player2"]
}
  • Add your new tag ("myservers") to the Destination (dst) array.
  • Add the Linux usernames defined in your cloud-config ("player1", "player2") to the Destination users (users) array.
  • Change "action" from "check" to "accept" for seamless SSH access.

Create a Tailscale auth key

  1. Generate an auth key via the Tailscale Admin Keys panel with these configurations:
  • Reusable: Enabled
  • Pre-authorized: Enabled
  • Tags: Choose the newly created tag: tag:myservers
  1. Store the newly created auth key in Keychain:
./store-ts-key-keychain.sh

(Note: This creates an entry named tailscale-auth-key-dev-server in your Keychain).

Build and provision the VM

Start the VM and add it to your tailnet

Once run.sh finishes authenticating the machine, you can connect directly over your tailnet using Tailscale SSH or jump straight into the machine locally via OrbStack:

  • MagicDNS name: ssh player1@dev-server
  • built-in local SSH proxy: ssh player1@dev-server@orb
  • CLI: orb -m dev-server

Once Tailscale SSH is setup correctly, it's simple to use git remotely. Let's assume that we have a git repo on dev-server. We can simply clone it directly without any extra authentication:

git clone player1@dev-server:~/my-proj

  • dev-server.yml: A cloud-init recipe that specifies environment configurations, system locales, default development packages, user access profiles and installation tasks for the Tailscale engine.
  • build.sh: Builds and provisions an Ubuntu 25.10 environment using the cloud.init configuration in dev-server.yml.
  • run.sh: Pulls the auth key from Keychain and brings up the Tailscale interface (tailscale up) inside the VM with SSH enabled.
  • cleanup.sh: Fully tears down the setup. It logs out the VM from your tailnet, destroys the OrbStack instance, and wipes the auth key from Keychain.
  • store-ts-key-keychain.sh: Copies the auth key from the system clipboard and stores it in Keychain.
联系我们 contact @ memedata.com