VSCode 远程 SSH 连接下 Copilot Claude Agent 异常修复
在使用 VSCode 进行远程 SSH 开发时,部分用户反馈 Copilot 插件无法加载 Claude 模型,或 Agent 模式出现编辑异常。
问题现象
开启本地代理后,本地模式下 Copilot 可正常显示 Claude 模型,但在远程 SSH 会话中会出现连接异常。尝试在本地 settings.json 中添加如下配置以强制扩展在本地运行:
{
"http.proxy": "http://127.0.0.1:1082",
"remote.extensionKind": {
"GitHub.copilot": ["ui"],
"GitHub.copilot-chat": ["ui"],
"pub.name": ["ui"]
}
}
此时虽然模型可见且基础问答可用,但启用 Agent 模式编辑时会报错:copilotAllow edits to sensitive files?The model wants to edit files outside of your workspace。这是因为强制将扩展运行在本地导致远程工作区路径无法被正确识别。
解决方案
正确的做法是将代理穿透至远程服务器,而非仅配置本地。
- 注释本地配置:将本地
settings.json中上述强制本地运行的代码注释掉。 - 配置 SSH 隧道:在 SSH 配置文件(如
~/.ssh/config)中将本地代理端口映射到远程服务器。 - 配置远程环境:在远程服务器的 VSCode
settings.json中配置代理信息。
{
"http.proxy": "http://127.0.0.1:1082",
"http.proxyStrictSSL"

