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: [email protected] 
[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 [email protected]

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

参考文章:

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

相关推荐
榆榆欸29 分钟前
6.实现 Reactor 模式的 EventLoop 和 Server 类
linux·服务器·网络·c++·tcp/ip
还是鼠鼠1 小时前
Node.js Express 处理静态资源
前端·javascript·vscode·node.js·json·express
漫天转悠2 小时前
本地Git仓库SSH同步到Gitee(码云)仓库的完整指南(附:SourceTree同步仓库)
git·gitee·ssh
快乐的蛋糕2 小时前
【Linux】进程间通信(IPC)-- 无名管道、命名管道
linux·服务器·网络
XMYX-02 小时前
如何加强 SSH 安全:内网和专用网络环境下的防护策略
网络·安全·ssh
H1346948902 小时前
服务器定时备份,服务器定时备份有哪些方法?
运维·服务器·负载均衡
H1346948902 小时前
ftp服务器备份,ftp服务器备份的方法
运维·服务器·负载均衡
Python之栈3 小时前
再见VS Code!Google IDE 正颠覆传统开发体验
ide·vscode·python
共享家95273 小时前
Linux基础命令:开启系统操作之旅
linux·运维·服务器
卷卷的小趴菜学编程3 小时前
算法篇-------------双指针法
c语言·开发语言·c++·vscode·算法·leetcode·双指针法