Mac + Tailscale
你的 Mac 运行 herdr 和 hmob 网关。iPhone 通过你的 tailnet 访问网关,因此不会向局域网或互联网暴露任何内容。
1. 安装网关
Section titled “1. 安装网关”curl -fsSL https://hmob-app.github.io/install.sh | sh如果脚本提示 ~/.local/bin 不在 PATH 中,请将其加入(以 zsh 为例):
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc && exec zsh2. 获取 Mac 的 Tailscale 地址
Section titled “2. 获取 Mac 的 Tailscale 地址”macOS 版 Tailscale App 的命令行工具位于 App 包内:
TS=/Applications/Tailscale.app/Contents/MacOS/Tailscalecommand -v tailscale >/dev/null && TS=tailscaleTS_IP="$("$TS" ip -4)"echo "$TS_IP" # 100.x.y.z3. 设置登录时运行网关
Section titled “3. 设置登录时运行网关”只在 Tailscale 地址上监听:
hmob install-service --bind "$TS_IP"hmob status这会安装一个 launchd agent,在登录时启动,停止后自动重启。日志写入 ~/Library/Logs/。
4. 配对 iPhone
Section titled “4. 配对 iPhone”hmob pair --url "https://$TS_IP:8443"在 iPhone 上打开 Tailscale,然后打开 Hmob App,点击 扫描配对二维码,扫描终端中显示的二维码。该二维码有效期 5 分钟,只能使用一次。
保持 Mac 可访问
Section titled “保持 Mac 可访问”只有在 Mac 处于唤醒且在线状态时,iPhone 才能访问网关。对于长时间运行的 agent 任务,请在接通电源时阻止睡眠(系统设置 → 电池 → 选项,台式 Mac 为 节能),或在终端中运行 caffeinate -s。
| 现象 | 检查项 |
|---|---|
| 配对超时 | iPhone 上已打开 Tailscale;hmob status 显示服务正在运行;"$TS" ping <iphone-name> 能连通手机。 |
| “A TLS error caused the secure connection to fail” | 你手动输入了地址,或通过主机名配对。请重新扫描用 --url https://$TS_IP:8443 生成的二维码进行配对。 |
| 终端打开的是普通 shell | 找不到 herdr。安装 herdr 后重新安装服务:hmob install-service --bind "$TS_IP"。 |