当前位置: 首页 > article >正文

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

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


[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中,生成公钥指令:

ssh-keygen -t rsa

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

ssh xxx@192.168.146.128

在这里插入图片描述
如果不成功需要解决该问题,如果成功了基本就能连上了:
在这里插入图片描述

参考文章:
https://blog.csdn.net/qq_46106285/article/details/132360266


http://www.kler.cn/a/611614.html

相关文章:

  • 使用react 引入相对路径文件
  • 学习日记0327
  • xxljob阻塞处理策略设置为单机串行导致的bug
  • PyTorch 深度学习实战(22):多智能体强化学习(MARL)
  • 堆的常见应用2
  • 3.27【A】cv homework
  • 手撕LRU缓存Java版(带输入输出)
  • 《基于机器学习发电数据电量预测》开题报告
  • 学习本地部署DeepSeek的过程(基于LM Studio)
  • 自然语言处理|金融舆情解析:智能事件抽取与风险预警之道
  • 算法-动态规划三
  • 学习threejs,使用Sprite精灵、SpriteMaterial精灵材质
  • 企业内训|DeepSeek技术革命、算力范式重构与场景落地洞察-某头部券商
  • 精选10个好用的WordPress免费主题
  • ELK stack基础架构
  • Android TextView实现跑马灯效果性能优化
  • 用shell脚本,批量备份MySQL中所有数据库,并批量还原!
  • asp.net进销存软件WEB进销存ERP软件库存玻璃行业
  • SQLite优化实践
  • 【设计模式】策略模式(Strategy Pattern)详解