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

相关推荐
東雪蓮☆13 分钟前
深入理解 LVS-DR 模式与 Keepalived 高可用集群
linux·运维·服务器·lvs
乌萨奇也要立志学C++39 分钟前
【Linux】进程概念(二):进程查看与 fork 初探
linux·运维·服务器
绿箭柠檬茶2 小时前
Ubuntu 服务器配置转发网络访问
服务器·网络·ubuntu
獭.獭.2 小时前
Linux -- 信号【上】
linux·运维·服务器
路由侠内网穿透4 小时前
本地部署 GPS 跟踪系统 Traccar 并实现外部访问
运维·服务器·网络·windows·tcp/ip
ZERO_pan7 小时前
服务器装机遇到的问题
运维·服务器
l1t7 小时前
利用DeepSeek实现服务器客户端模式的DuckDB原型
服务器·c语言·数据库·人工智能·postgresql·协议·duckdb
杀气丶7 小时前
Linux下运行芙蕾雅天堂2【俄文简译L2FATER】
运维·服务器·天堂2·l2fater·l2fater.cn
喵手7 小时前
玩转Java网络编程:基于Socket的服务器和客户端开发!
java·服务器·网络
Tisfy11 小时前
服务器 - 从一台服务器切换至另一台服务器(损失数十条访客记录)
运维·服务器