1. Cursor Remote SSH 连不上,先别急着重装
你打开 Cursor,点右下角绿色角标选择Connect to Host,转了几圈之后弹出一行红字:Could not establish connection to "xxx": Connecting was canceled或者The remote host does not meet the requirements。这时候大多数人第一反应是卸载 Cursor 重装,或者怀疑服务器挂了。实际上,Cursor 的 Remote SSH 连接失败,九成以上出在三个地方:SSH 配置本身、密钥认证链路、以及服务器上残留的.cursor_server目录。
这篇内容就是围绕这三个点展开的。我会先带你把报错信息读明白,再给出一份可以直接复制修改的 SSH config 骨架和 Cursor remote ssh 配置骨架,然后一步步验证连接是否恢复。适合正在用 Cursor 做远程开发、被 remote ssh 报错卡住的同学。整个过程不需要你懂太多网络底层,跟着命令敲就行。
先说一个判断原则:如果终端里ssh user@host能正常登录,但 Cursor 连不上,那问题基本在 Cursor 侧的配置或服务端残留文件;如果终端里ssh本身就报错,那先修 SSH,Cursor 的问题会跟着一起消失。这个判断能帮你省掉一半的排查时间。
2. 用 TaoToken 补齐模型侧能力,让排查更顺
远程连接修好之后,你大概率会继续在 Cursor 里写代码、让模型帮忙看报错。这时候如果模型调用不稳定,排查体验会很割裂。我自己的做法是把模型调用统一走 TaoToken,它的 API 地址是https://taotoken.net/api,官网在https://taotoken.net/?utm_source=taotoken_aicg_blog_end&utm_medium=csdn&utm_campaign=rewrite&utm_content=。你可以在 Cursor 的设置里把自定义模型指向这个地址,也可以在终端里用 curl 先验证通不通。
需要先拿到 API Key,入口在这里:https://taotoken.net/api-keys?utm_source=taotoken_aicg_blog_end&utm_content=api_keys&utm_campaign=rewrite。拿到之后,模型对话调试可以用https://taotoken.net/models?utm_source=taotoken_aicg_blog_end&utm_content=models&utm_campaign=rewrite,长期编码或者跑 Agent 的话,Coding Plan 更合适:https://taotoken.net/coding-plan?utm_source=taotoken_aicg_blog_end&utm_content=coding_plan&utm_campaign=rewrite。控制台在https://taotoken.net/console?utm_source=taotoken_aicg_blog_end&utm_content=console&utm_campaign=rewrite,接入文档在https://taotoken.net/doc?utm_source=taotoken_aicg_blog_end&utm_content=doc&utm_campaign=rewrite。如果你用的是 Claude Code 那套,Anthropic 兼容入口是https://taotoken.net/claude-code-anthropic?utm_source=taotoken_aicg_blog_end&utm_content=claude_code_anthropic&utm_campaign=rewrite。
这一步不是必须的,但它能让你在修远程连接的同时,保持模型辅助可用,排查效率会高不少。
3. 可复制的 SSH config 与 Cursor remote ssh 配置骨架
3.1 本地 SSH config 骨架
先看你本机的~/.ssh/config。很多人这里写得太随意,导致 Cursor 解析失败。下面这份骨架可以直接改:
Host myserver HostName 192.168.1.100 User deploy Port 22 IdentityFile ~/.ssh/id_ed25519 IdentitiesOnly yes ServerAliveInterval 30 ServerAliveCountMax 6 TCPKeepAlive yes几个关键点:HostName写 IP 或域名,不要带协议;IdentityFile指向私钥,权限必须是600;IdentitiesOnly yes能避免 SSH 拿一堆密钥挨个试导致超时。改完先在本机终端跑ssh myserver,能进去再谈 Cursor。
3.2 Cursor remote ssh 配置骨架
Cursor 的 Remote SSH 配置存在~/.ssh/config同一份文件里,但它会额外读取settings.json里的 remote 相关项。你可以在 Cursor 设置里搜索remote.SSH,重点确认这几项:
{ "remote.SSH.configFile": "~/.ssh/config", "remote.SSH.connectTimeout": 60, "remote.SSH.useLocalServer": true, "remote.SSH.showLoginTerminal": true, "remote.SSH.remotePlatform": { "myserver": "linux" } }connectTimeout默认偏短,网络稍慢就断,调到 60 秒能救回不少“连接被取消”的情况。showLoginTerminal打开后,连接过程会弹终端,报错信息更完整,排查时非常有用。
3.3 服务端残留目录清理
这是最容易被忽略的一步。Cursor 会在服务器上生成.cursor_server目录,版本不匹配或上次连接中断后,这个目录可能损坏,导致新连接一直卡住。登录服务器后执行:
ls -la ~/.cursor_server rm -rf ~/.cursor_server删掉之后不要手动重建,Cursor 下次连接会自己生成。如果你用的是 VS Code 迁移过来的配置,还要检查扩展目录里有没有冲突的 remote ssh 扩展,必要时在 Cursor 扩展市场重新装一遍 Remote - SSH。
4. 验证请求与成功结果
配置改完,按下面顺序验证,每一步都要看到预期结果再往下走。
第一步,本机终端验证 SSH:
ssh -v myserver-v会打印详细握手过程。看到Authenticated to 192.168.1.100和debug1: channel 0: new就说明 SSH 链路通了。如果卡在Offering public key,说明密钥没被服务器接受,回去检查authorized_keys。
第二步,验证服务器端目录权限:
chmod 700 ~/.ssh chmod 600 ~/.ssh/authorized_keys权限不对是密钥认证失败的常见原因,SSH 会直接拒绝。
第三步,回到 Cursor,Ctrl+Shift+P输入Remote-SSH: Connect to Host,选择myserver。如果showLoginTerminal开着,你会看到一个终端窗口滚动日志,最后出现Server is ready或者左下角显示SSH: myserver,就说明连接恢复了。
第四步,验证模型侧是否可用(如果你接了 TaoToken):
curl https://taotoken.net/api/v1/models \ -H "Authorization: Bearer $TAOTOKEN_API_KEY"返回模型列表 JSON 就说明 API 链路正常,可以继续在 Cursor 里调用。
5. 本篇常见错排查
5.1 报错Connecting was canceled
优先看connectTimeout是不是太短,再确认本机网络到服务器的 22 端口是否可达。用nc -vz 192.168.1.100 22测一下,不通就是网络层问题,跟 Cursor 无关。
5.2 报错Permission denied (publickey)
九成是密钥问题。检查三件事:私钥权限600、公钥是否写进服务器~/.ssh/authorized_keys、IdentityFile路径是否正确。用ssh -v看它到底拿了哪把钥匙。
5.3 报错The remote host does not meet the requirements
通常是服务器上的.cursor_server版本和本地 Cursor 不匹配。删掉~/.cursor_server重连即可。如果还不行,检查服务器 glibc 版本是否过低,老系统可能跑不了新版 server。
5.4 连接成功但一直转圈、文件树出不来
多半是服务端磁盘满了或者 inode 耗尽。df -h和df -i看一眼,清理后再重连。另外检查~/.cursor_server所在分区是否有写权限。
5.5 从 VS Code 迁移后扩展冲突
VS Code 的 remote ssh 扩展和 Cursor 自带的可能打架。做法是在 Cursor 里卸载从 VS Code 同步过来的 remote 扩展,从 Cursor 扩展市场重新安装,然后重启 Cursor。
6. 修好之后,把模型调用也理顺
远程连接恢复只是第一步,真正影响日常效率的是模型调用稳不稳。我现在的习惯是:SSH 配置固定成上面那份骨架,.cursor_server出问题就删,模型侧统一走 TaoToken 的 API。API Key 在https://taotoken.net/api-keys?utm_source=taotoken_aicg_blog_end&utm_content=api_keys&utm_campaign=rewrite拿,接入细节看文档https://taotoken.net/doc?utm_source=taotoken_aicg_blog_end&utm_content=doc&utm_campaign=rewrite。如果你主要跑长任务编码,直接上 Coding Planhttps://taotoken.net/coding-plan?utm_source=taotoken_aicg_blog_end&utm_content=coding_plan&utm_campaign=rewrite更省心。
最后留一个我踩过的坑:改完~/.ssh/config后,Cursor 有时会缓存旧的连接信息,记得Ctrl+Shift+P执行Remote-SSH: Kill VS Code Server on Host,把服务端进程清掉再重连,比反复重启 Cursor 管用得多。