RobMcC
RobMcC

Reputation: 412

How to double ssh with vscode

To ssh into a remote station I do the following:

ssh -L 4001:connect.iop.kcl.ac.uk:4000 [email protected]

I'm then asked for a password which I enter, and I then do:

ssh -YX [email protected]

and am asked for another password, after which I am where I want to be.

I want to set this up in vs code using the Remote-SSH extension but am running into difficulty

When I try and add the first step (ssh -L 4001:connect.iop.kcl.ac.uk:4000 [email protected]), my config file looks as follows:

Host cana.iop.kcl.ac.uk
  HostName cana.iop.kcl.ac.uk
  LocalForward 4001:connect.iop.kcl.ac.uk:4000
  User dmzromc

But when I try and connect I get the following error:

[16:23:45.992] Log Level: 3
[16:23:45.993] [email protected]
[16:23:45.994] darwin x64
[16:23:45.995] SSH Resolver called for "ssh-remote+cana.host.institution", attempt 1
[16:23:45.995] SSH Resolver called for host: cana.host.institution
[16:23:45.995] Setting up SSH remote "cana.host.institution"
[16:23:46.020] Using commit id "78a4c91400152c0f27ba4d363eb56d2835f9903a" and quality "stable" for server
[16:23:46.023] Install and start server if needed
[16:23:46.031] Checking ssh with "ssh -V"
[16:23:46.071] > OpenSSH_7.9p1, LibreSSL 2.7.3
[16:23:46.075] Running script with connection command: ssh -T -D 55893 -o ConnectTimeout=15 cana.iop.kcl.ac.uk bash
[16:23:46.364] > /Users/user1/.ssh/config line 15: Missing target argument.
[16:23:46.364] Got some output, clearing connection timeout
[16:23:46.835] "install" terminal command done
[16:23:46.835] Install terminal quit with output: /Users/user1/.ssh/config line 15: Missing target argument.
[16:23:46.836] Received install output: /Users/user1/.ssh/config line 15: Missing target argument.
[16:23:46.837] Stopped parsing output early. Remaining text: /Users/user1/.ssh/config line 15: Missing target argument.
[16:23:46.837] Failed to parse remote port from server output
[16:23:46.838] Resolver error: 
[16:23:46.842] ------

Any advice much appreciated

Upvotes: 0

Views: 2148

Answers (1)

raychz
raychz

Reputation: 1175

I had the same issue when forwarding a database port and fixed it by manually editing my ssh config as follows:

BEFORE (using the problematic config that VSCode auto generates)

Host mysshhost
  HostName mysshhost
  LocalForward 5432:mydatabaseservername:5432
  User myuserid

AFTER (works for me)

Host mysshhost
  HostName mysshhost
  LocalForward localhost:5432 mydatabaseservername:5432
  User myuserid

So in your case, the config should look something like:

Host cana.iop.kcl.ac.uk
  HostName cana.iop.kcl.ac.uk
  LocalForward localhost:4001 connect.iop.kcl.ac.uk:4000
  User dmzromc

Upvotes: 1

Related Questions