1. Windows 调试机安装 SSH Server

以管理员身份打开 PowerShell:

Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

Start-Service sshd
Set-Service sshd -StartupType Automatic

Get-Service sshd
Get-NetTCPConnection -LocalPort 22 -State Listen

安装通常会自动创建防火墙规则。建议限制为 Claude 所在电脑的 IP:

Set-NetFirewallRule `
  -Name OpenSSH-Server-In-TCP `
  -Profile Private `
  -RemoteAddress 192.168.1.50

192.168.1.50 换成本地运行 Claude 的电脑地址。微软 OpenSSH Server 安装说明

2. 配置 SSH 密钥

在运行 C的电脑上:

ssh-keygen -t ed25519

将公钥内容放到 Windows 调试账户的:

C:\Users\codexdbg\.ssh\authorized_keys

建议创建专用的普通账户 codexdbg,不要一开始就给管理员权限。确认密钥登录正常后,再关闭密码登录。

3. 在远端 Windows 安装 Claude 

winget install OpenJS.NodeJS.LTS
npm install -g @openai/codex

codex.cmd --version
codex.cmd login

如果 PowerShell提示 codex.ps1 被执行策略阻止,直接使用 codex.cmd,或者执行:

Set-ExecutionPolicy -Scope CurrentUser RemoteSigned

4. 在控制端添加 SSH 配置

编辑 %USERPROFILE%\.ssh\config

Host win-debug
    HostName 192.168.1.100
    User codexdbg
    IdentityFile ~/.ssh/id_ed25519

先测试:

ssh win-debug

然后在 ChatGPT 桌面版打开:

设置 → Connections(连接)→ SSH → 添加 win-debug → 选择远端项目目录

Codex 会通过 SSH 在远端启动自己的服务,调试命令、编译和文件修改都会发生在那台 Windows 上。

需要注意:

  • 当前浏览器里的普通聊天无法直接访问你局域网中的 Windows;需要使用本地  桌面版或本地 Claude  CLI。

  • SSH 适合排查日志、注册表、服务、进程、Dump、编译和命令行程序。

  • 你常遇到的 SetWindowDisplayAffinity、CEF、GPU、窗口焦点等桌面问题,仅靠 SSH 不够;最好同时保留物理控制台、VNC 或 Computer Use。RDP 会改变 Windows 会话和图形环境,可能让问题表现不同。

  • 如果是内核驱动崩溃,需要另外配置 WinDbg/KDNET,SSH只能用于辅助收集信息。

ssh syz@192.168.60.136
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ED25519 key sent by the remote host is
SHA256:RPySQDk/11l1G9h7vwJ//J7x0bIT02tiJrFfgcOIuDQ.
Please contact your system administrator.
Add correct host key in C:\\Users\\VISION16Pro/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in C:\\Users\\VISION16Pro/.ssh/known_hosts:18
Host key for 192.168.60.136 has changed and you have requested strict checking.
Host key verification failed.  

怎么办

这是一个非常常见的 SSH 错误。

出现这个警告的原因是:你的电脑曾经连接过 192.168.60.136,并在本地记录了它的安全密钥。但现在这台服务器的密钥发生了变化(在局域网中,这通常是因为服务器重装了系统,或者这个 IP 分配给了一台新机器)。SSH 为了防止“中间人攻击”,自动拦截了连接。

解决这个问题非常简单,只需要清除本地旧的密钥记录即可。你有两种方法可以解决:

方法一:使用命令行一键清除(最简单)

打开你的命令行终端(CMD 或 PowerShell),直接运行以下命令:

Bash

ssh-keygen -R 192.168.60.136

运行后,系统会自动将失效的旧密钥从记录中删除,并备份原文件。

完成之后,你只需要重新执行 ssh syz@192.168.60.136,当提示 Are you sure you want to continue connecting (yes/no)? 时,输入 yes 并回车即可。

方法二:手动修改文件

错误提示中其实已经精准地告诉你问题出在哪里了:

Offending ECDSA key in C:\\Users\\VISION16Pro/.ssh/known_hosts:18

如果你想手动解决:

  1. 按下 Win + R 打开运行窗口,输入 notepad C:\Users\VISION16Pro\.ssh\known_hosts 并回车,用记事本打开该文件。

  2. 找到第 18 行(就是以 192.168.60.136 开头的那一行)。

  3. 将这一整行彻底删除。

  4. 保存文件并关闭,然后重新尝试 SSH 连接即可。

Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐