ssh 适用于 putty 和终端,但不适用于 vscode 远程 ssh(错误:无法建立连接)

发布于 2025-01-20 16:01:11 字数 4835 浏览 0 评论 0原文

最近,我遇到了VSCODE远程SSH扩展名。一切都很好,但是SSH突然存在问题(无法建立连接,连接时间,拒绝(public键,密码))

在终端上运行ssh或Putty的工作正常,所以我对问题是什么不知所措。

我的vscode版本:

Version: 1.66.1 (user setup)
Commit: 8dfae7a5cd50421d10cd99cb873990460525a898
Date: 2022-04-06T14:50:12.141Z
Electron: 17.2.0
Chromium: 98.0.4758.109
Node.js: 16.13.0
V8: 9.8.177.11-electron.0
OS: Windows_NT x64 10.0.19044

我当前的节点版本,

node 16.4.2
npm 8.5.0

我的猜测可能是由于我最近使用NVM降级到较低版本的node.js造成的,但是在安装了其他版本的node.js之后,它仍然能够工作。 。我试图安装最新版本,但问题仍然存在。我已经完成的其他事情:

  1. 更改远程SSH
  2. 重新安装VSCODE
  3. 的版本删除SSH配置文件

如果没有人能够解决此特定问题,请建议使用可以从SSH编辑文件的其他IDE。想要通过某种GUI完成我的工作,但我也不确定要搜索什么。

这是我尝试SSH时的输出日志。我已经编辑了一些名字。

[11:17:42.388] Log Level: 2
[11:17:42.390] [email protected]
[11:17:42.390] win32 x64
[11:17:42.406] SSH Resolver called for "ssh-remote+sunfire", attempt 1
[11:17:42.407] "remote.SSH.useLocalServer": false
[11:17:42.408] "remote.SSH.showLoginTerminal": false
[11:17:42.408] "remote.SSH.remotePlatform": {"xxx.xxx.xxx.xxx.xxx":"linux","xxx":"linux"}
[11:17:42.409] "remote.SSH.path": undefined
[11:17:42.409] "remote.SSH.configFile": undefined
[11:17:42.409] "remote.SSH.useFlock": true
[11:17:42.409] "remote.SSH.lockfilesInTmp": false
[11:17:42.409] "remote.SSH.localServerDownload": auto
[11:17:42.410] "remote.SSH.remoteServerListenOnSocket": false
[11:17:42.410] "remote.SSH.showLoginTerminal": false
[11:17:42.410] "remote.SSH.defaultExtensions": []
[11:17:42.410] "remote.SSH.loglevel": 2
[11:17:42.411] "remote.SSH.enableDynamicForwarding": true
[11:17:42.411] "remote.SSH.enableRemoteCommand": false
[11:17:42.411] "remote.SSH.serverPickPortsFromRange": {}
[11:17:42.412] "remote.SSH.serverInstallPath": {}
[11:17:42.446] SSH Resolver called for host: sunfire
[11:17:42.447] Setting up SSH remote "sunfire"
[11:17:42.509] Using commit id "8dfae7a5cd50421d10cd99cb873990460525a898" and quality "stable" for server
[11:17:42.515] Install and start server if needed
[11:18:36.858] Checking ssh with "ssh -V"
[11:18:36.925] > OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2

[11:18:36.933] Running script with connection command: ssh -T -D 49776 sunfire bash
[11:18:36.939] Terminal shell path: C:\Windows\System32\cmd.exe
[11:18:37.299] > ]0;C:\Windows\System32\cmd.exe
[11:18:37.299] Got some output, clearing connection timeout
[11:18:37.608] > Password: 
[11:18:37.609] Showing password prompt
[11:18:40.335] Got password response
[11:18:40.336] "install" wrote data to terminal: "*******"
[11:18:40.372] > 
[11:18:40.533] > 1dd6cf88d3c6: running
[11:18:40.591] > Unsupported platform: SunOS
> 1dd6cf88d3c6: start        
> exitCode==35==
> listeningOn====
> osReleaseId==SunOS==       
> arch====
> tmpDir==/tmp==
> platform====
> unpackResult====
> didLocalDownload==0==      
> downloadTime====
> installTime====
> extInstallTime====
> serverStartTime====        
> 1dd6cf88d3c6: end
[11:18:40.592] Received install output:         
exitCode==35==
listeningOn====
osReleaseId==SunOS==       
arch====
tmpDir==/tmp==
platform====
unpackResult====
didLocalDownload==0==      
downloadTime====
installTime====
extInstallTime====
serverStartTime====        

[11:18:40.594] Failed to parse remote port from server output
[11:18:40.595] Resolver error: Error: 
    at Function.Create (c:\Users\Raihan\.vscode\extensions\ms-vscode-remote.remote-ssh-0.78.0\out\extension.js:1:586041)
    at Object.t.handleInstallOutput (c:\Users\Raihan\.vscode\extensions\ms-vscode-remote.remote-ssh-0.78.0\out\extension.js:1:584693)
    at Object.t.tryInstall (c:\Users\Raihan\.vscode\extensions\ms-vscode-remote.remote-ssh-0.78.0\out\extension.js:1:681924)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async c:\Users\Raihan\.vscode\extensions\ms-vscode-remote.remote-ssh-0.78.0\out\extension.js:1:644564
    at async Object.t.withShowDetailsEvent (c:\Users\Raihan\.vscode\extensions\ms-vscode-remote.remote-ssh-0.78.0\out\extension.js:1:647909)
    at async Object.t.resolve (c:\Users\Raihan\.vscode\extensions\ms-vscode-remote.remote-ssh-0.78.0\out\extension.js:1:645643)
    at async c:\Users\Raihan\.vscode\extensions\ms-vscode-remote.remote-ssh-0.78.0\out\extension.js:1:722950
[11:18:40.605] ------




[11:18:41.251] > grep: illegal option -- a
> grep: illegal option -- E
> Usage: grep -hblcnsviw pattern file . . .
> grep: illegal option -- a
> grep: illegal option -- E
> Usage: grep -hblcnsviw pattern file . . .
[11:18:41.977] "install" terminal command done
[11:18:41.985] Install terminal quit with output: Usage: grep -hblcnsviw pattern file . . .

I recently came across this issue with the Vscode remote ssh extension. Everything was working fine but ssh suddenly has issues (connection could not be established, connection timed out, Permission Denied(public key, password))

Running ssh on terminal or Putty works fine so I'm at a loss as to what the issue is.

My Vscode version:

Version: 1.66.1 (user setup)
Commit: 8dfae7a5cd50421d10cd99cb873990460525a898
Date: 2022-04-06T14:50:12.141Z
Electron: 17.2.0
Chromium: 98.0.4758.109
Node.js: 16.13.0
V8: 9.8.177.11-electron.0
OS: Windows_NT x64 10.0.19044

My current node version

node 16.4.2
npm 8.5.0

My guess is that it might be due to node.js as I had recently used NVM to downgrade to a lower version but it was still able to work a day after installing a different version of node.js. I tried to install the latest version but the issue persists. Other things I have done:

  1. Changing versions of Remote ssh
  2. Reinstalling vscode
  3. deleting the ssh config files

If nobody is able to solve this specific issue, do recommend a different IDE that can edit files from ssh. Would like to still complete my work with some kind of GUI but I'm also not sure what exactly to search for.

Here is the output log when I try to ssh. I have redacted some names.

[11:17:42.388] Log Level: 2
[11:17:42.390] [email protected]
[11:17:42.390] win32 x64
[11:17:42.406] SSH Resolver called for "ssh-remote+sunfire", attempt 1
[11:17:42.407] "remote.SSH.useLocalServer": false
[11:17:42.408] "remote.SSH.showLoginTerminal": false
[11:17:42.408] "remote.SSH.remotePlatform": {"xxx.xxx.xxx.xxx.xxx":"linux","xxx":"linux"}
[11:17:42.409] "remote.SSH.path": undefined
[11:17:42.409] "remote.SSH.configFile": undefined
[11:17:42.409] "remote.SSH.useFlock": true
[11:17:42.409] "remote.SSH.lockfilesInTmp": false
[11:17:42.409] "remote.SSH.localServerDownload": auto
[11:17:42.410] "remote.SSH.remoteServerListenOnSocket": false
[11:17:42.410] "remote.SSH.showLoginTerminal": false
[11:17:42.410] "remote.SSH.defaultExtensions": []
[11:17:42.410] "remote.SSH.loglevel": 2
[11:17:42.411] "remote.SSH.enableDynamicForwarding": true
[11:17:42.411] "remote.SSH.enableRemoteCommand": false
[11:17:42.411] "remote.SSH.serverPickPortsFromRange": {}
[11:17:42.412] "remote.SSH.serverInstallPath": {}
[11:17:42.446] SSH Resolver called for host: sunfire
[11:17:42.447] Setting up SSH remote "sunfire"
[11:17:42.509] Using commit id "8dfae7a5cd50421d10cd99cb873990460525a898" and quality "stable" for server
[11:17:42.515] Install and start server if needed
[11:18:36.858] Checking ssh with "ssh -V"
[11:18:36.925] > OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2

[11:18:36.933] Running script with connection command: ssh -T -D 49776 sunfire bash
[11:18:36.939] Terminal shell path: C:\Windows\System32\cmd.exe
[11:18:37.299] > ]0;C:\Windows\System32\cmd.exe
[11:18:37.299] Got some output, clearing connection timeout
[11:18:37.608] > Password: 
[11:18:37.609] Showing password prompt
[11:18:40.335] Got password response
[11:18:40.336] "install" wrote data to terminal: "*******"
[11:18:40.372] > 
[11:18:40.533] > 1dd6cf88d3c6: running
[11:18:40.591] > Unsupported platform: SunOS
> 1dd6cf88d3c6: start        
> exitCode==35==
> listeningOn====
> osReleaseId==SunOS==       
> arch====
> tmpDir==/tmp==
> platform====
> unpackResult====
> didLocalDownload==0==      
> downloadTime====
> installTime====
> extInstallTime====
> serverStartTime====        
> 1dd6cf88d3c6: end
[11:18:40.592] Received install output:         
exitCode==35==
listeningOn====
osReleaseId==SunOS==       
arch====
tmpDir==/tmp==
platform====
unpackResult====
didLocalDownload==0==      
downloadTime====
installTime====
extInstallTime====
serverStartTime====        

[11:18:40.594] Failed to parse remote port from server output
[11:18:40.595] Resolver error: Error: 
    at Function.Create (c:\Users\Raihan\.vscode\extensions\ms-vscode-remote.remote-ssh-0.78.0\out\extension.js:1:586041)
    at Object.t.handleInstallOutput (c:\Users\Raihan\.vscode\extensions\ms-vscode-remote.remote-ssh-0.78.0\out\extension.js:1:584693)
    at Object.t.tryInstall (c:\Users\Raihan\.vscode\extensions\ms-vscode-remote.remote-ssh-0.78.0\out\extension.js:1:681924)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async c:\Users\Raihan\.vscode\extensions\ms-vscode-remote.remote-ssh-0.78.0\out\extension.js:1:644564
    at async Object.t.withShowDetailsEvent (c:\Users\Raihan\.vscode\extensions\ms-vscode-remote.remote-ssh-0.78.0\out\extension.js:1:647909)
    at async Object.t.resolve (c:\Users\Raihan\.vscode\extensions\ms-vscode-remote.remote-ssh-0.78.0\out\extension.js:1:645643)
    at async c:\Users\Raihan\.vscode\extensions\ms-vscode-remote.remote-ssh-0.78.0\out\extension.js:1:722950
[11:18:40.605] ------




[11:18:41.251] > grep: illegal option -- a
> grep: illegal option -- E
> Usage: grep -hblcnsviw pattern file . . .
> grep: illegal option -- a
> grep: illegal option -- E
> Usage: grep -hblcnsviw pattern file . . .
[11:18:41.977] "install" terminal command done
[11:18:41.985] Install terminal quit with output: Usage: grep -hblcnsviw pattern file . . .

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暗藏城府 2025-01-27 16:01:11

除了删除远程上的 .vscode 服务器之外,我们忘记的两个麻烦步骤是:

从已知主机删除指纹。
当您出于任何原因有理由重新连接到主机时,这种情况很常见!

请参阅此答案
对于 Windows,找到 C:\Users\\.ssh\known_host ;对于 Linux,找到 /home//.ssh/known_hosts 目录。找到并删除当前主机的指纹;我刚刚清除了整个文本,因为我不再使用主机

And 2:
设置配置文件的绝对路径,请按照此答案

但我确信第一步可能是您的情况!

Apart from deleting the .vscode server on your remote, 2 trouble steps we forget are:

Deleting fingerprint from known host.
This is common when you have reason to re-connect to host either for any reason!

Ref to this answer.
For Windows, locate C:\Users\<your_user_name>\.ssh\known_host and for Linux /home/<your_user_name>/.ssh/known_hosts dir. Locate and delete finger print of your current host; I just cleared the whole text since I no longer use the host

And 2:
Set absolute path for your config file, follow this answer

Am sure the first step is likely your case though!

年华零落成诗 2025-01-27 16:01:11

将此代码添加到setter.json

 "remote.SSH.remotePlatform": {
    "$yourRemoteServerName": "linux"
 }

add this code in setting.json in file->Preference

 "remote.SSH.remotePlatform": {
    "$yourRemoteServerName": "linux"
 }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文