feat: add one-line remote support scripts (Windows + Mac/Linux)

- remote-help.ps1: auto-install SSH + bore tunnel for Windows
- remote-help.sh: auto-enable SSH + bore tunnel for Mac/Linux
- Users run one command, get connection info to send to support
This commit is contained in:
dongsheng123132
2026-03-18 17:29:16 +08:00
parent 6ec0559010
commit 6d7bd42abe
2 changed files with 237 additions and 0 deletions

122
website/remote-help.ps1 Normal file
View File

@@ -0,0 +1,122 @@
# ============================================================
# U-Claw 远程协助 (Windows)
# 用法: irm https://u-claw.org/remote-help.ps1 | iex
# ============================================================
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$OutputEncoding = [System.Text.Encoding]::UTF8
try { chcp 65001 | Out-Null } catch {}
Set-ExecutionPolicy Bypass -Scope Process -Force -ErrorAction SilentlyContinue
Clear-Host
Write-Host ""
Write-Host " ============================================" -ForegroundColor Cyan
Write-Host " U-Claw 远程协助 - 一键开启" -ForegroundColor Cyan
Write-Host " 技术支持将通过 SSH 帮你安装/调试" -ForegroundColor Cyan
Write-Host " ============================================" -ForegroundColor Cyan
Write-Host ""
# ---- Step 1: 安装并启动 SSH ----
Write-Host " [1/3] 检查 SSH 服务 ..." -ForegroundColor White
$sshdService = Get-Service sshd -ErrorAction SilentlyContinue
if (-not $sshdService) {
Write-Host " 正在安装 OpenSSH Server需要几分钟..." -ForegroundColor Yellow
$ErrorActionPreference = "Continue"
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 2>&1 | Out-Null
$ErrorActionPreference = "Stop"
}
# 启动 SSH
Start-Service sshd -ErrorAction SilentlyContinue
Set-Service -Name sshd -StartupType Automatic -ErrorAction SilentlyContinue
# 验证
$sshdService = Get-Service sshd -ErrorAction SilentlyContinue
if ($sshdService -and $sshdService.Status -eq 'Running') {
Write-Host " [OK] SSH 服务已启动" -ForegroundColor Green
} else {
Write-Host " [!] SSH 启动失败,尝试备用方案..." -ForegroundColor Red
# 尝试重新启动
try {
Start-Service sshd
Write-Host " [OK] SSH 服务已启动" -ForegroundColor Green
} catch {
Write-Host " [!] SSH 安装失败,请以管理员身份运行 PowerShell" -ForegroundColor Red
Write-Host " 右键开始菜单 → '终端(管理员)' → 重新运行本命令" -ForegroundColor Yellow
Read-Host " 按回车退出"
exit 1
}
}
Write-Host ""
# ---- Step 2: 防火墙放行 ----
Write-Host " [2/3] 配置防火墙 ..." -ForegroundColor White
$ErrorActionPreference = "Continue"
New-NetFirewallRule -Name "OpenSSH-Server" -DisplayName "OpenSSH Server" -Direction Inbound -Protocol TCP -LocalPort 22 -Action Allow -ErrorAction SilentlyContinue 2>&1 | Out-Null
$ErrorActionPreference = "Stop"
Write-Host " [OK] 防火墙已放行 SSH" -ForegroundColor Green
Write-Host ""
# ---- Step 3: 开启隧道 ----
Write-Host " [3/3] 开启远程通道 ..." -ForegroundColor White
$BORE_DIR = "$env:TEMP\uclaw-remote"
$BORE_EXE = "$BORE_DIR\bore.exe"
if (-not (Test-Path $BORE_EXE)) {
New-Item -ItemType Directory -Force -Path $BORE_DIR | Out-Null
$boreUrl = "https://github.com/ekzhang/bore/releases/download/v0.5.2/bore-v0.5.2-x86_64-pc-windows-msvc.zip"
$boreZip = "$BORE_DIR\bore.zip"
Write-Host " 下载隧道工具..." -ForegroundColor Yellow
$ErrorActionPreference = "Continue"
try {
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri $boreUrl -OutFile $boreZip -UseBasicParsing
} catch {
# 备用: 用 curl
try {
& curl.exe -sL $boreUrl -o $boreZip
} catch {
Write-Host " [!] 下载失败,请检查网络(需要能访问 GitHub" -ForegroundColor Red
Read-Host " 按回车退出"
exit 1
}
}
$ErrorActionPreference = "Stop"
Expand-Archive -Path $boreZip -DestinationPath $BORE_DIR -Force
Remove-Item $boreZip -ErrorAction SilentlyContinue
}
if (-not (Test-Path $BORE_EXE)) {
Write-Host " [!] 隧道工具下载失败" -ForegroundColor Red
Read-Host " 按回车退出"
exit 1
}
# 获取用户信息
$USERNAME = $env:USERNAME
$COMPUTERNAME = $env:COMPUTERNAME
Write-Host ""
Write-Host " ============================================" -ForegroundColor Green
Write-Host " 远程协助已就绪!" -ForegroundColor Green
Write-Host " ============================================" -ForegroundColor Green
Write-Host ""
Write-Host " 你的用户名: $USERNAME" -ForegroundColor White
Write-Host " 你的电脑名: $COMPUTERNAME" -ForegroundColor White
Write-Host ""
Write-Host " 正在开启远程通道..." -ForegroundColor Yellow
Write-Host " 开启后,把下面显示的连接信息发给技术支持" -ForegroundColor Yellow
Write-Host ""
Write-Host " ============================================" -ForegroundColor Cyan
Write-Host " 提示: 关闭此窗口即可断开远程连接" -ForegroundColor DarkGray
Write-Host " ============================================" -ForegroundColor Cyan
Write-Host ""
# 启动 bore 隧道(会阻塞,显示端口号)
& $BORE_EXE local 22 --to bore.pub

115
website/remote-help.sh Normal file
View File

@@ -0,0 +1,115 @@
#!/bin/bash
# ============================================================
# U-Claw 远程协助 (Mac/Linux)
# 用法: curl -fsSL https://u-claw.org/remote-help.sh | bash
# ============================================================
set -e
GREEN='\033[0;32m'
CYAN='\033[0;36m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m'
clear
echo ""
echo -e "${CYAN} ============================================${NC}"
echo -e "${CYAN} U-Claw 远程协助 - 一键开启${NC}"
echo -e "${CYAN} 技术支持将通过 SSH 帮你安装/调试${NC}"
echo -e "${CYAN} ============================================${NC}"
echo ""
# ---- Step 1: 检查 SSH ----
echo -e " [1/3] 检查 SSH 服务 ..."
if [[ "$(uname)" == "Darwin" ]]; then
# macOS: 开启远程登录
SSHD_STATUS=$(sudo systemsetup -getremotelogin 2>/dev/null | grep -i "on" || true)
if [ -z "$SSHD_STATUS" ]; then
echo -e "${YELLOW} 正在开启远程登录(需要输入密码)...${NC}"
sudo systemsetup -setremotelogin on
fi
echo -e "${GREEN} [OK] SSH 服务已启动${NC}"
else
# Linux
if command -v systemctl &>/dev/null; then
if ! systemctl is-active --quiet sshd 2>/dev/null && ! systemctl is-active --quiet ssh 2>/dev/null; then
echo -e "${YELLOW} 正在启动 SSH...${NC}"
sudo systemctl start sshd 2>/dev/null || sudo systemctl start ssh 2>/dev/null || {
echo -e "${YELLOW} 正在安装 OpenSSH...${NC}"
sudo apt-get install -y openssh-server 2>/dev/null || sudo yum install -y openssh-server 2>/dev/null
sudo systemctl start sshd 2>/dev/null || sudo systemctl start ssh
}
fi
fi
echo -e "${GREEN} [OK] SSH 服务已启动${NC}"
fi
echo ""
# ---- Step 2: 防火墙 ----
echo -e " [2/3] 配置防火墙 ..."
if [[ "$(uname)" == "Darwin" ]]; then
echo -e "${GREEN} [OK] macOS 无需额外配置${NC}"
else
sudo ufw allow 22 2>/dev/null || true
echo -e "${GREEN} [OK] 防火墙已放行${NC}"
fi
echo ""
# ---- Step 3: 开启隧道 ----
echo -e " [3/3] 开启远程通道 ..."
BORE_DIR="/tmp/uclaw-remote"
mkdir -p "$BORE_DIR"
ARCH=$(uname -m)
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
if [[ "$OS" == "darwin" ]]; then
if [[ "$ARCH" == "arm64" ]]; then
BORE_URL="https://github.com/ekzhang/bore/releases/download/v0.5.2/bore-v0.5.2-aarch64-apple-darwin.tar.gz"
else
BORE_URL="https://github.com/ekzhang/bore/releases/download/v0.5.2/bore-v0.5.2-x86_64-apple-darwin.tar.gz"
fi
else
BORE_URL="https://github.com/ekzhang/bore/releases/download/v0.5.2/bore-v0.5.2-x86_64-unknown-linux-musl.tar.gz"
fi
BORE_EXE="$BORE_DIR/bore"
if [ ! -f "$BORE_EXE" ]; then
echo -e "${YELLOW} 下载隧道工具...${NC}"
curl -sL "$BORE_URL" | tar xz -C "$BORE_DIR"
fi
if [ ! -f "$BORE_EXE" ]; then
echo -e "${RED} [!] 下载失败,请检查网络(需要能访问 GitHub${NC}"
exit 1
fi
chmod +x "$BORE_EXE"
USERNAME=$(whoami)
HOSTNAME=$(hostname)
echo ""
echo -e "${GREEN} ============================================${NC}"
echo -e "${GREEN} 远程协助已就绪!${NC}"
echo -e "${GREEN} ============================================${NC}"
echo ""
echo -e " 你的用户名: ${CYAN}$USERNAME${NC}"
echo -e " 你的电脑名: ${CYAN}$HOSTNAME${NC}"
echo ""
echo -e "${YELLOW} 正在开启远程通道...${NC}"
echo -e "${YELLOW} 开启后,把下面显示的连接信息发给技术支持${NC}"
echo ""
echo -e "${CYAN} ============================================${NC}"
echo -e " 提示: 按 Ctrl+C 即可断开远程连接"
echo -e "${CYAN} ============================================${NC}"
echo ""
# 启动 bore 隧道
"$BORE_EXE" local 22 --to bore.pub