Windows 打开SSH 提供给Claude Code 作为测试机器的通道方案

创建于:2026-07-31 修改于:2026-07-31

Windows 打开SSH 提供给Claude Code 作为测试机器的通道方案

1. 安装并启动 OpenSSH 服务端

Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Start-Service sshd
Set-Service -Name sshd -StartupType Automatic

2. 放行防火墙(通常自动加,保险起见)

New-NetFirewallRule -Name sshd -DisplayName ‚OpenSSH Server' -Enabled True `
-Direction Inbound -Protocol TCP -Action Allow -LocalPort 22

3. 默认 shell 设为 PowerShell(否则默认 cmd,很多命令不好用)

New-ItemProperty -Path “HKLM:\SOFTWARE\OpenSSH” -Name DefaultShell `
-Value “C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe” -PropertyType String -Force

4. 授权我的公钥

$key = ‚ssh-ed25519 xxxxxxxxxxxxxxxxxxxxxxxxx claude-silk-debug'

第 4 步分两种情况(很关键,弄错就登不上):

弄好后跟我说一声,我这边直接连:ssh -i <私钥> [email protected]。私钥我生成在会话临时目录里(没放进仓库,也没碰你的 ~/.ssh),用完你随时在 Windows 上把那行公钥删掉即可撤销。

💬 评论区