Chowder
Chowder

Reputation: 126

ssh works on putty and terminal but not vscode Remote ssh (Error: connection could not be established)

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 . . .

Upvotes: 5

Views: 9549

Answers (2)

DAVID AJAYI
DAVID AJAYI

Reputation: 2154

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!

Upvotes: 1

HasH
HasH

Reputation: 948

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

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

Upvotes: 0

Related Questions