0

What is the easiest way to connect to remote server using SSH on Windows 10? Is there a VSCode extension to do this? What is the purpose of .PEM file below?

I am unable to connect to remote ubuntu server at aws from VSCode on windows 10 using SSH. I am using Remote SSH extension. I have received Server.PEM file along with following command from my client:

ssh -i ~/.ssh/Server.pem ubuntu@ec2-55-131-129-128.us-east-2.compute.amazonaws.com

I select Linux for platform of remote host in extesion prompt. But I am getting following error:

Visual Studio Code

Could not establish connection to "ec2-55-131-129-128.us-east-2.compute.amazonaws.com".

[Close Remote] [Retry] [More Actions...]

When I click [More Actions...] button, the extension ask me to select configuration file. I tried with .PEM file path but still the same error.

Here is the output log:

[16:47:03.391] Log Level: 2
[16:47:03.456] SSH Resolver called for "ssh-remote+ec2-55-131-129-128.us-east-2.compute.amazonaws.com", attempt 1
[16:47:03.457] "remote.SSH.useLocalServer": false
[16:47:03.458] "remote.SSH.showLoginTerminal": false
[16:47:03.459] "remote.SSH.remotePlatform": {}
[16:47:03.474] "remote.SSH.path": undefined
[16:47:03.475] "remote.SSH.configFile": undefined
[16:47:03.476] "remote.SSH.useFlock": true
[16:47:03.476] "remote.SSH.lockfilesInTmp": false
[16:47:03.477] "remote.SSH.localServerDownload": auto
[16:47:03.477] "remote.SSH.remoteServerListenOnSocket": false
[16:47:03.479] "remote.SSH.showLoginTerminal": false
[16:47:03.479] "remote.SSH.defaultExtensions": []
[16:47:03.480] "remote.SSH.loglevel": 2
[16:47:03.481] "remote.SSH.enableDynamicForwarding": true
[16:47:03.481] "remote.SSH.enableRemoteCommand": false
[16:47:03.481] "remote.SSH.serverPickPortsFromRange": {}
[16:47:03.482] "remote.SSH.serverInstallPath": {}
[16:47:03.496] VS Code version: 1.80.1
[16:47:03.496] Remote-SSH version: remote-ssh@0.102.0
[16:47:03.496] win32 x64
[16:47:03.502] SSH Resolver called for host: ec2-55-131-129-128.us-east-2.compute.amazonaws.com
[16:47:03.503] Setting up SSH remote "ec2-55-131-129-128.us-east-2.compute.amazonaws.com"
[16:47:03.520] Using commit id "74f6148eb9ea00507ec113ec51c489d6ffb4b771" and quality "stable" for server
[16:47:03.540] Install and start server if needed
[16:48:05.855] Checking ssh with "C:\Program Files (x86)\Common Files\Oracle\Java\javapath\ssh.exe -V"
[16:48:05.863] Got error from ssh: spawn C:\Program Files (x86)\Common Files\Oracle\Java\javapath\ssh.exe ENOENT
[16:48:05.864] Checking ssh with "C:\Windows\system32\ssh.exe -V"
[16:48:05.869] Got error from ssh: spawn C:\Windows\system32\ssh.exe ENOENT
[16:48:05.869] Checking ssh with "C:\Windows\ssh.exe -V"
[16:48:05.876] Got error from ssh: spawn C:\Windows\ssh.exe ENOENT
[16:48:05.877] Checking ssh with "C:\Windows\System32\Wbem\ssh.exe -V"
[16:48:05.880] Got error from ssh: spawn C:\Windows\System32\Wbem\ssh.exe ENOENT
[16:48:05.881] Checking ssh with "C:\Windows\System32\WindowsPowerShell\v1.0\ssh.exe -V"
[16:48:05.885] Got error from ssh: spawn C:\Windows\System32\WindowsPowerShell\v1.0\ssh.exe ENOENT
[16:48:05.886] Checking ssh with "C:\Windows\System32\OpenSSH\ssh.exe -V"
[16:48:05.993] > OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2
[16:48:05.994] > 

[16:48:06.010] Running script with connection command: "C:\Windows\System32\OpenSSH\ssh.exe" -T -D 51940 "ec2-55-131-129-128.us-east-2.compute.amazonaws.com" bash
[16:48:06.015] Terminal shell path: C:\Windows\System32\cmd.exe
[16:48:06.465] > ]0;C:\Windows\System32\cmd.exe
[16:48:06.466] Got some output, clearing connection timeout
[16:48:09.123] > ubuntu@ec2-55-131-129-128.us-east-2.compute.amazonaws.com: Permission denied (pu
> blickey).
[16:48:09.135] > The process tried to write to a nonexistent pipe.
[16:48:10.431] "install" terminal command done
[16:48:10.432] Install terminal quit with output: blickey).
[16:48:10.432] Received install output: blickey).
[16:48:10.434] Failed to parse remote port from server output
[16:48:10.442] Resolver error: Error: 
    at m.Create (c:\Users\HT\.vscode\extensions\ms-vscode-remote.remote-ssh-0.102.0\out\extension.js:1:584145)
    at t.handleInstallOutput (c:\Users\HT\.vscode\extensions\ms-vscode-remote.remote-ssh-0.102.0\out\extension.js:1:582705)
    at t.tryInstall (c:\Users\HT\.vscode\extensions\ms-vscode-remote.remote-ssh-0.102.0\out\extension.js:1:681881)
    at async c:\Users\HT\.vscode\extensions\ms-vscode-remote.remote-ssh-0.102.0\out\extension.js:1:644110
    at async t.withShowDetailsEvent (c:\Users\HT\.vscode\extensions\ms-vscode-remote.remote-ssh-0.102.0\out\extension.js:1:647428)
    at async t.resolve (c:\Users\HT\.vscode\extensions\ms-vscode-remote.remote-ssh-0.102.0\out\extension.js:1:645160)
    at async c:\Users\HT\.vscode\extensions\ms-vscode-remote.remote-ssh-0.102.0\out\extension.js:1:720916
[16:48:10.465] ------

Syed Rafey Husain
  • 153
  • 1
  • 1
  • 7
  • In the log you'll note two things: The SSH command isn't attempting to use the key in the .pem file connect, and it's failing due to a permission denied error. You'll need to [setup the key file](https://stackoverflow.com/a/60305052) in ssh's config file so VS Code can connect. – Anon Coward Jul 26 '23 at 14:23

2 Answers2

0

What you are doing looks correct, but ensure you have allowed access to your IP address in the security group.

Visit the security group page and select the group associated with your EC2 instance: https://ap-southeast-2.console.aws.amazon.com/ec2/home?#SecurityGroups:

Edit the inbound rules and ensure there is an entry which matches 'SSH' as the Type and your ip address/32 as the 'Source', eg 123.123.123/32

0

It turns out my VS Code got garbage! I have to Completely uninstall VsCode,

  1. Do the regular Uninstall in "Apps & features."
  2. In strat, search "environment variable" and remove all the references for `Visual Studio Code or any installation path.
  3. In file Explore, type %APPDATA% and remove the folder called Code.
  4. And got to %LOCALAPPDATA% and deleted the folder code if it exists.
  5. Got to %USERPROFILE%\AppData\Roaming and remove the folder code
Syed Rafey Husain
  • 153
  • 1
  • 1
  • 7