vscode 通过Remote-ssh远程连接服务器报错 could not establish connection to ubuntu

vscode 通过Remote-ssh插件远程连接服务器报错 could not establish connection to ubuntu,并且出现下面的错误打印:

cpp 复制代码
[21:00:57.307] Log Level: 2 
[21:00:57.350] SSH Resolver called for "ssh-remote+ubuntu", attempt 1 
[21:00:57.359] remote.SSH.useLocalServer = false 
[21:00:57.359] remote.SSH.useExecServer = true 
[21:00:57.359] remote.SSH.bindHost = {} 
[21:00:57.359] remote.SSH.showLoginTerminal = false 
[21:00:57.359] remote.SSH.remotePlatform = {} 
[21:00:57.359] remote.SSH.path = 
[21:00:57.360] remote.SSH.configFile = 
[21:00:57.360] remote.SSH.useFlock = true 
[21:00:57.360] remote.SSH.lockfilesInTmp = false 
[21:00:57.360] remote.SSH.localServerDownload = auto 
[21:00:57.360] remote.SSH.remoteServerListenOnSocket = false 
[21:00:57.360] remote.SSH.defaultExtensions = [] 
[21:00:57.361] remote.SSH.defaultExtensionsIfInstalledLocally = [] 
[21:00:57.361] remote.SSH.loglevel = 2 
[21:00:57.361] remote.SSH.enableDynamicForwarding = true 
[21:00:57.361] remote.SSH.enableRemoteCommand = false 
[21:00:57.365] remote.SSH.serverPickPortsFromRange = {} 
[21:00:57.365] remote.SSH.serverInstallPath = {} 
[21:00:57.365] remote.SSH.permitPtyAllocation = false 
[21:00:57.365] remote.SSH.preferredLocalPortRange = undefined 
[21:00:57.366] remote.SSH.useCurlAndWgetConfigurationFiles = false 
[21:00:57.366] remote.SSH.experimental.chat = true 
[21:00:57.366] remote.SSH.experimental.enhancedSessionLogs = true 
[21:00:57.366] remote.SSH.httpProxy = {"*":""} 
[21:00:57.366] remote.SSH.httpsProxy = {"*":""} 
[21:00:57.379] VS Code version: 1.98.2 
[21:00:57.380] Remote-SSH version: remote-ssh@0.118.0 
[21:00:57.380] win32 x64 
[21:00:57.384] SSH Resolver called for host: ubuntu 
[21:00:57.384] Setting up SSH remote "ubuntu" 
[21:00:57.397] Using commit id "ddc367ed5c8936efe395cffeec279b04ffd7dxxx" and quality "stable" for server 
[21:00:57.398] Extensions to install: 
[21:00:57.406] Install and start server if needed 
[21:01:17.677] Checking ssh with "C:\Windows\system32\ssh.exe -V" 
[21:01:17.680] Got error from ssh: spawn C:\Windows\system32\ssh.exe ENOENT 
[21:01:17.681] Checking ssh with "C:\Windows\ssh.exe -V" 
[21:01:17.683] Got error from ssh: spawn C:\Windows\ssh.exe ENOENT 
[21:01:17.683] Checking ssh with "C:\Windows\System32\Wbem\ssh.exe -V" 
[21:01:17.684] Got error from ssh: spawn C:\Windows\System32\Wbem\ssh.exe ENOENT 
[21:01:17.685] Checking ssh with "C:\Windows\System32\WindowsPowerShell\v1.0\ssh.exe -V" 
[21:01:17.686] Got error from ssh: spawn C:\Windows\System32\WindowsPowerShell\v1.0\ssh.exe ENOENT 
[21:01:17.687] Checking ssh with "C:\Windows\System32\OpenSSH\ssh.exe -V" 
[21:01:17.784] > OpenSSH_for_Windows_9.5p1, LibreSSL 3.8.2 
[21:01:17.811] Running script with connection command: "C:\Windows\System32\OpenSSH\ssh.exe" -T -D 8289 ubuntu sh 
[21:01:17.813] Generated SSH command: 'type "C:\Users\JAXON_~1\AppData\Local\Temp\vscode-linux-multi-line-command-ubuntu-802208376.sh" | "C:\Windows\System32\OpenSSH\ssh.exe" -T -D 8289 ubuntu sh' 
[21:01:17.814] Using connect timeout of 17 seconds 
[21:01:17.816] Terminal shell path: C:\Windows\System32\cmd.exe 
[21:01:18.494] > 
[21:01:18.494] Got some output, clearing connection timeout 
[21:01:18.509] > Bad permissions. Try removing permissions for user: \\Everyone (S-1-1-0) on file > C:/Users/Jaxon_xxx/.ssh/config. > Bad owner or permissions on C:\\Users\\Jaxon_xxx/.ssh/config > 过程试图写入的管道不存在。 
[21:01:19.784] "install" terminal command done 
[21:01:19.784] Install terminal quit with output: 过程试图写入的管道不存在。 
[21:01:19.785] Received install output: 过程试图写入的管道不存在。 
[21:01:19.786] WARN: $PLATFORM is undefined in installation script output. Errors may be dropped. 
[21:01:19.786] Failed to parse remote port from server output 
[21:01:19.790] Resolver error: Error: at y.Create (c:\Users\Jaxon_xxx\.vscode\extensions\ms-vscode-remote.remote-ssh-0.118.0\out\extension.js:2:740625) at t.handleInstallOutput (c:\Users\Jaxon_xxx\.vscode\extensions\ms-vscode-remote.remote-ssh-0.118.0\out\extension.js:2:738706) at t.tryInstall (c:\Users\Jaxon_xxx\.vscode\extensions\ms-vscode-remote.remote-ssh-0.118.0\out\extension.js:2:856299) at async c:\Users\Jaxon_xxx\.vscode\extensions\ms-vscode-remote.remote-ssh-0.118.0\out\extension.js:2:815123 at async t.withShowDetailsEvent (c:\Users\Jaxon_xxx\.vscode\extensions\ms-vscode-remote.remote-ssh-0.118.0\out\extension.js:2:818374) at async R (c:\Users\Jaxon_xxx\.vscode\extensions\ms-vscode-remote.remote-ssh-0.118.0\out\extension.js:2:811578) at async t.resolve (c:\Users\Jaxon_xxx\.vscode\extensions\ms-vscode-remote.remote-ssh-0.118.0\out\extension.js:2:815775) at async c:\Users\Jaxon_xxx\.vscode\extensions\ms-vscode-remote.remote-ssh-0.118.0\out\extension.js:2:1102718 
[21:01:19.802] ------ 
[21:01:19.803] No hints found in the recent session. 
[21:01:20.600] Opening exec server for ssh-remote+ubuntu 
[21:01:20.667] Initizing new exec server for ssh-remote+ubuntu 
[21:01:20.667] Using commit id "ddc367ed5c8936efe395cffeec279b04ffd7dxxx" and quality "stable" for server 
[21:01:20.668] Extensions to install: 
[21:01:20.680

做了以下操作后成功:

1‌.删除无关用户权限‌:(xxx是你windows系统用户名称)

打开 ‌文件资源管理器‌ → 进入路径 C:\Users\xxx.ssh。

右键点击 config 文件 → ‌属性‌ → ‌安全‌ → ‌高级‌ → 移除 Everyone 或其他无关用户的权限。

确保仅当前用户(如 xxx)有 ‌完全控制‌权限。

另外注意事项:

1.确保 C:\Users\xxx.ssh\config中配置正确,比如linux终端命令行中的打印 xxx@ubuntu ,host是就是ubuntu,user就是 xxx,ip要保证和192.168.146.121能够ping通

Host ubuntu

HostName 192.168.146.121

User xxx

2.确保windows中生成的ssh的公钥id_rsa.pub拷贝到linux的~/.ssh/authorized_keys中,linux中的公钥id_rsa.pub我也拷贝到了windows的C:\Users\Jaxon_hyj.ssh\known_hosts中,生成公钥指令:

bash 复制代码
ssh-keygen -t rsa

3.试下windows上直接ssh连接服务器是否成功:

bash 复制代码
ssh xxx@192.168.146.128

如果不成功需要解决该问题,如果成功了基本就能连上了:

参考文章:

https://blog.csdn.net/qq_46106285/article/details/132360266

相关推荐
Snasph6 小时前
GNU Make 用户手册(中文版)
服务器·算法·gnu
广州灵眸科技有限公司6 小时前
瑞芯微RV1126B开发板(EASY-EAI-PI2) Easy-Eai编译环境准备与更新
服务器·前端·人工智能·python·深度学习
Esaka_Forever7 小时前
uv init 完整用法(Python 最快包管理器)
服务器·python·uv
溜达的大象7 小时前
服务器挂了等用户报障?我用Prometheus搭了一套监控告警,服务器出状况第一时间通知我
服务器·php·prometheus
闪电悠米9 小时前
黑马点评-Redisson-01_why_redisson
java·服务器·网络·数据库·缓存·wpf
棒棒的唐10 小时前
Vscode Continue插件 集成 本地llama.cpp大模型实现代码补全
ide·vscode·编辑器
tudoSearcher11 小时前
日志、指标、链路追踪:可观测性三支柱深度解析
运维·服务器·网络·prometheus
xier_ran11 小时前
【infra之路】Linux基础命令与系统排查
linux·运维·服务器
c2385611 小时前
linux基础2
linux·运维·服务器
养肥胖虎11 小时前
多Agent开发笔记:为什么4个Codex加1个Claude会把cpu跑满
vscode·agent·codex