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

相关推荐
电脑能手1 小时前
[保姆级教程] 解决不同局域网电脑无法SSH的问题
运维·ssh·电脑
tan77º1 小时前
【Linux网络编程】Socket - UDP
linux·服务器·网络·c++·udp
悠悠小茉莉2 小时前
Win11 安装 Visual Studio(保姆教程 - 更新至2025.07)
c++·ide·vscode·python·visualstudio·visual studio
szxinmai主板定制专家2 小时前
【精密测量】基于ARM+FPGA的多路光栅信号采集方案
服务器·arm开发·人工智能·嵌入式硬件·fpga开发
你不知道我是谁?2 小时前
负载均衡--四层、七层负载均衡的区别
运维·服务器·负载均衡
SZ1701102313 小时前
华为云 银河麒麟 vscode远程连接
ide·vscode·华为云
yanjiee3 小时前
需要scl来指定编译器的clangd+cmake在vscode/cursor开发环境下的配置
ide·vscode·编辑器
九丝城主4 小时前
2025使用VM虚拟机安装配置Macos苹果系统下Flutter开发环境保姆级教程--中篇
服务器·flutter·macos·vmware
码出钞能力4 小时前
linux内核模块的查看
linux·运维·服务器
小皮侠6 小时前
nginx的使用
java·运维·服务器·前端·git·nginx·github