When to use this skill
- Need to connect to remote hosts via SSH (小m, Peter's Mac Mini, etc.)
- Troubleshooting Tailscale SSH connection issues
- Executing remote commands
- Configuring SSH tunnels or port forwarding
- Handling host key verification issues
- Bypassing the proxy to access intranet devices
Known host list
| Hostname | Tailscale IP | Username | Purpose |
|---|---|---|---|
| 小m (Mac Mini M2) | Dynamic | danielli | Daniel's Mac Mini |
| Peter's Mac Mini | 100.118.109.75 | peterqiu | Peter's team |
| daniel-ubuntu | 100.112.88.20 | aa | Local machine (Ubuntu) |
⚠️ Note: The Tailscale IP may change and should be obtained dynamically
Core features
1. Get dynamic Tailscale IP
# 获取指定主机的当前 Tailscale IP
tailscale status | grep "主机名" | awk '{print $1}'
2. Standardized SSH connection
# 推荐:使用 Tailscale MagicDNS 名称
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null 用户@主机名.tail0db0a3.ts.net
# 或使用动态 IP
IP=$(tailscale status | grep "主机名" | awk '{print $1}')
ssh -o StrictHostKeyChecking=no 用户@$IP
3. Bypass proxy (important!)
The local Clash proxy intercepts 100.x.x.x traffic, causing 502 errors:
# SSH 不需要(走 Tailscale),但 HTTP/API 调用需要绕过
curl --noproxy "*" "http://TAILSCALE_IP:端口/api/endpoint"
# Python
requests.get(url, proxies={"http": None, "https": None})
4. Host status check
# 检查主机是否在线
tailscale ping 主机名 --timeout=5s
# 查看详细状态
tailscale status | grep 主机名
Helper scripts
connect.sh - Smart SSH connection
#!/bin/bash
# 使用:./connect.sh <主机名> [命令]
# 示例:./connect.sh daniellimac-mini "ollama list"
HOST=$1
CMD=$2
# 获取动态 IP
IP=$(tailscale status | grep "$HOST" | awk '{print $1}')
if [ -z "$IP" ]; then
echo "❌ 主机 $HOST 未找到或不在线"
tailscale status | grep -E "offline|online" | head -5
exit 1
fi
# 检查是否在线
STATUS=$(tailscale status | grep "$HOST" | awk '{print $NF}')
if [[ "$STATUS" == "offline"* ]]; then
echo "⚠️ 主机 $HOST 当前离线 ($STATUS)"
exit 1
fi
echo "🔗 连接 $HOST ($IP)..."
if [ -z "$CMD" ]; then
# 交互式 SSH
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null danielli@$IP
else
# 执行命令
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null danielli@$IP "$CMD"
fi
tunnel.sh - Port forwarding
#!/bin/bash
# 使用:./tunnel.sh <主机名> <远程端口> [本地端口]
# 示例:./tunnel.sh daniellimac-mini 11434 11434
HOST=$1
REMOTE_PORT=$2
LOCAL_PORT=${3:-$REMOTE_PORT}
IP=$(tailscale status | grep "$HOST" | awk '{print $1}')
if [ -z "$IP" ]; then
echo "❌ 主机 $HOST 未找到"
exit 1
fi
echo "🔗 建立隧道: localhost:$LOCAL_PORT -> $HOST:$REMOTE_PORT"
ssh -N -L $LOCAL_PORT:localhost:$REMOTE_PORT danielli@$IP
check-host.sh - Host diagnostics
#!/bin/bash
# 使用:./check-host.sh <主机名>
HOST=$1
echo "=== Tailscale 状态 ==="
tailscale status | grep -E "$HOST|online" | head -5
echo ""
echo "=== IP 地址 ==="
IP=$(tailscale status | grep "$HOST" | awk '{print $1}')
echo "IP: $IP"
echo ""
echo "=== 连通性测试 ==="
if ping -c 2 -W 3 $IP > /dev/null 2>&1; then
echo "✅ Ping 成功"
else
echo "❌ Ping 失败"
fi
echo ""
echo "=== SSH 测试 ==="
timeout 5 ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=3 danielli@$IP "echo 'SSH 连接成功'" 2>&1
Common issues
Q: SSH connection timeout
- Check Tailscale status:
tailscale status - Confirm the host is online:
tailscale ping 主机名 - Check whether the firewall allows SSH (port 22)
Q: Host key verification failed
Use -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
Q: HTTP request returns 502
Interference from the local Clash proxy; add --noproxy "*" or set no_proxy=100.0.0.0/8
Q: Tailscale IP changes
Always use tailscale status to get the current IP; do not hardcode it
Trigger words
- "SSH connection"
- "Connect to remote host"
- "Tailscale SSH"
- "SSH tunnel"
- "Port forwarding"
- "Remote command execution"
- "SSH issue"
Related files
~/clawd/MEMORY.md- Host configuration information~/.ssh/known_hosts- Known host keys~/.ssh/config- SSH configuration file
Created: 2026-03-06