microsoft / vscode-remote-release

Visual Studio Code Remote Development: Open any folder in WSL, in a Docker container, or on a remote machine using SSH and take advantage of VS Code's full feature set.
https://aka.ms/vscode-remote
Other
3.65k stars 285 forks source link

Remote - SSH extension try to map local port zero #216

Closed AlexBu closed 5 years ago

AlexBu commented 5 years ago

Issue Type: Bug

connect to a remote host specified from ~/.ssh/config
the connection stopped with message "Could not establish connection to "xxx". Illegal argument: port".
With the full log in "OUTPUT" window, I can see the extension try to map remote port 42007 to local port 0, while port 0 is invalid.

SSH Resolver called for "ssh-remote+aliyun" SSH Resolver called for host: aliyun Setting up SSH remote "aliyun" Using commit id "473af338e1bd9ad4d9853933da1cd9d5d9e07dc9" and quality "insider" for server Install and start server if needed

Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0-117-generic x86_64)

    Documentation: https://help.ubuntu.com
    Management: https://landscape.canonical.com
    Support: https://ubuntu.com/advantage
    New release '18.04.2 LTS' available.
    Run 'do-release-upgrade' to upgrade to it.

Welcome to Alibaba Cloud Elastic Compute Service !

mesg: ttyname failed: Inappropriate ioctl for device
bash: cannot set terminal process group (7824): Inappropriate ioctl for device
bash: no job control in this shell
Found existing installation...
mesg: ttyname failed: Inappropriate ioctl for device
Found running server...

    Reminder: You may only use this software with Visual Studio family products,
    as described in the license (https://go.microsoft.com/fwlink/?linkid=2077057)

ebaaff07-47c7-4d23-ad0e-65c0dd7d2fc6==42007==
"install" terminal command done
Received install output: ebaaff07-47c7-4d23-ad0e-65c0dd7d2fc6==42007==
Server is listening on port 42007
Spawning tunnel with: ssh aliyun -N -L localhost:0:localhost:42007
Spawned SSH tunnel between local port 0 and remote port 42007
Waiting for ssh tunnel to be ready
Tunneling remote port 42007 to local port 0
Resolving "ssh-remote+aliyun" to "localhost:0", attempt: 1
Illegal argument: port
Tunnel(42007) stderr: Bad local forwarding specification 'localhost:0:localhost:42007

VS Code version: Code - Insiders 1.34.0-insider (473af33, 2019-05-01T00:21:48.884Z) OS version: Darwin x64 18.2.0

Fetching remote diagnostics for 'SSH: aliyun' failed: Illegal argument: port System Info Extensions: none

roblourens commented 5 years ago

Seems that finding a free port failed for some reason.

AlexBu commented 5 years ago

The extension works correctly after a reboot on my MBP

roblourens commented 5 years ago

I will keep this open because we can handle this better...

harrism commented 5 years ago

Hit this today, also on a MBP, and reboot fixed it.

sebmaynard commented 5 years ago

I have this issue on Windows 10, rebooting doesn't help. Running the SSH Nightly also didn't help, but hid the error (but it still froze)

Server is listening on port 42444
Spawning tunnel with: ssh -t  "vm" -L localhost:0:localhost:42444 "echo -e 'Connected to SSH Host - Please do not close this terminal' && sleep infinity"
Spawned SSH tunnel between local port 0 and remote port 42444

Still seems to be trying to bind to port 0. I tried completely removing VS Code and all extensions and user settings in %appdata%\Code

xueyaodeai commented 5 years ago

I have the same problem in Windows 10.

"install" terminal command done
Received install output: 86ca28b4-a596-4ef8-ad23-a4ba3d6f5877==45403==37835==
Server is listening on port 45403
Using SSH config file "C:\Users\allan\.ssh\config"
Running script with connection command: "ssh" -L 127.0.0.1:0:127.0.0.1:45403    -F C:\Users\allan\.ssh\config
Dallas-Hays commented 5 years ago

I just started receiving this error yesterday, also Windows 10. I tried the insiders and the SSH nightly and still had the issue.

Are there any workarounds at this time?

roblourens commented 5 years ago

I have tried to improve the error handling here and make this less likely, but I'm not sure why we are failing to find a free port. If you still see it in the nightly build after next monday, please show me your logs.

Dallas-Hays commented 5 years ago

Hello, thanks for taking a look at this.

I’ve tried the nightly build you mentioned and I’m still seeing the error. Previously it looked like the other posters (specifically xueyaodeai's post). Now it pops up a window that says Could not establish connection to “dev-centos7”. Error establishing tunnel (Failed to find a free local port). and gives the option to close the remote or retry.

I am running Windows 10, the VSCode Insiders build, and the only extensions are the three that come with Remote – SSH.

Let me know if you need more information. Here are the Remote – SSH logs and my system info:

[19:37:13.327] remote-ssh-nightly@2019.7.31140
[19:37:13.327] win32 x64
[19:37:13.327] SSH Resolver called for "ssh-remote+dev-centos7", attempt 1
[19:37:13.327] SSH Resolver called for host: dev-centos7
[19:37:13.328] Setting up SSH remote "dev-centos7"
[19:37:13.332] Using commit id "81ed55af79f01e9e64c3438558d2c2233e382a5a" and quality "insider" for server
[19:37:13.335] Testing ssh with ssh -V
[19:37:13.426] ssh exited with code: 0
[19:37:13.426] Got stderr from ssh: OpenSSH_for_Windows_7.6p1, LibreSSL 2.6.4
[19:37:13.426] Running script with connection command: ssh -o ClearAllForwardings=true dev-centos7 bash
[19:37:13.432] Install and start server if needed
[19:37:13.603] >
[19:37:13.603] Got some output, clearing connection timeout
[19:37:14.065] > Running remote connection script
>
[19:37:14.091] > Acquiring lock on /root/.vscode-server-insiders/bin/81ed55af79f01e9e64c3438558d2
> c2233e382a5a/vscode-remote-lock.81ed55af79f01e9e64c3438558d2c2233e382a5a
> Found existing installation at /root/.vscode-server-insiders/bin/81ed55af79f01e9
> e64c3438558d2c2233e382a5a...
>
[19:37:14.155] > XDG_SESSION_ID=712
> SELINUX_ROLE_REQUESTED=
> SHELL=/bin/bash
> SSH_CLIENT=<my_ip_address> 61848 22
> SELINUX_USE_CURRENT_RANGE=
> USER=root
> VSCODE_AGENT_FOLDER=/root/.vscode-server-insiders
> PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
> MAIL=/var/mail/root
> PWD=/root
> LANG=en_US.UTF-8
> SELINUX_LEVEL_REQUESTED=
> HOME=/root
> SHLVL=2
> LOGNAME=root
> SSH_CONNECTION=<my_ip_address> 61848 <remote_ip_address> 22
> XDG_DATA_DIRS=/root/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/
> share:/usr/local/share:/usr/share
> LESSOPEN=||/usr/bin/lesspipe.sh %s
> XDG_RUNTIME_DIR=/run/user/0
> _=/usr/bin/printenv
> Starting server...
> Waiting for server log...
>
[19:37:14.651] >
> *
> * Reminder: You may only use this software with Visual Studio family products,
> * as described in the license (https://go.microsoft.com/fwlink/?linkid=2077057)
> *
>
> dab93d0b-4f33-4565-a0d1-c90079436fc9==45013==42592==
>
[19:37:14.652] Received install output: dab93d0b-4f33-4565-a0d1-c90079436fc9==45013==42592==
[19:37:14.652] Remote server is listening on port 45013
[19:37:14.941] "install" terminal command done
[19:37:17.654] Error establishing tunnel (Failed to find a free local port).
[19:37:17.654] Error establishing tunnel (Failed to find a free local port).
[19:37:17.654] ------
CPUs Intel(R) Xeon(R) Gold 6128 CPU @ 3.40GHz (12 x 3392)
GPU Status 2d_canvas: enabledflash_3d: enabledflash_stage3d: enabledflash_stage3d_baseline: enabledgpu_compositing: enabledmultiple_raster_threads: enabled_onnative_gpu_memory_buffers: disabled_softwareoop_rasterization: disabled_offprotected_video_decode: unavailable_offrasterization: enabledskia_deferred_display_list: disabled_offskia_renderer: disabled_offsurface_synchronization: enabled_onvideo_decode: enabledviz_display_compositor: disabled_offwebgl: enabledwebgl2: enabled
Load (avg) undefined
Memory (System) 63.63GB (52.56GB free)
Process Argv  
Screen Reader no
VM 0%
roblourens commented 5 years ago

Thanks for trying. I have changed the strategy for picking a free port, so maybe it will work in tomorrow's nightly build.

Dallas-Hays commented 5 years ago

Just tested the new build remote-ssh-nightly@2019.7.35535 and I'm still having issues, logs are below. I think that your recent change may have fixed the issue though and instead I'm having another problem.

There was an issue posted a couple of days ago that looks identical to what I'm seeing below: #1019 , the difference being they were running on the current release build 0.44.2. and I was on the nightly. Perhaps my logs will give a little more insight into their issue as well.

[15:00:07.169] remote-ssh-nightly@2019.7.35535
[15:00:07.169] win32 x64
[15:00:07.170] SSH Resolver called for "ssh-remote+dev-centos7", attempt 1
[15:00:07.170] SSH Resolver called for host: dev-centos7
[15:00:07.170] Setting up SSH remote "dev-centos7"
[15:00:07.187] Using commit id "6d82826e990407364d5c829b73602a19ecdf7d00" and quality "insider" for server
[15:00:07.190] Testing ssh with ssh -V
[15:00:07.275] ssh exited with code: 0
[15:00:07.275] Got stderr from ssh: OpenSSH_for_Windows_7.6p1, LibreSSL 2.6.4
[15:00:07.276] Running script with connection command: ssh -o ClearAllForwardings=true dev-centos7 bash
[15:00:07.280] Install and start server if needed
[15:00:07.557] >
[15:00:07.557] Got some output, clearing connection timeout
[15:00:07.898] > Running remote connection script
> Acquiring lock on /root/.vscode-server-insiders/bin/6d82826e990407364d5c829b7360
> 2a19ecdf7d00/vscode-remote-lock.6d82826e990407364d5c829b73602a19ecdf7d00
> Migrating .vscode-remote to /root/.vscode-server-insiders...
>
[15:00:07.934] > Installing to /root/.vscode-server-insiders/bin/6d82826e990407364d5c829b73602a19
> ecdf7d00...
> Downloading with wget
>
[15:00:23.248] > Download complete
>
[15:00:23.932] > XDG_SESSION_ID=1387
> SELINUX_ROLE_REQUESTED=
> SHELL=/bin/bash
> SSH_CLIENT=<my_ip_address> 55126 22
> SELINUX_USE_CURRENT_RANGE=
> USER=root
> VSCODE_AGENT_FOLDER=/root/.vscode-server-insiders
> PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
> MAIL=/var/mail/root
> PWD=/root
> LANG=en_US.UTF-8
> SELINUX_LEVEL_REQUESTED=
> HOME=/root
> SHLVL=2
> LOGNAME=root
> SSH_CONNECTION=<my_ip_address> 55126 <remote_ip_address> 22
> XDG_DATA_DIRS=/root/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/
> share:/usr/local/share:/usr/share
> LESSOPEN=||/usr/bin/lesspipe.sh %s
> XDG_RUNTIME_DIR=/run/user/0
> _=/usr/bin/printenv
> OLDPWD=/root/.vscode-server-insiders/bin/6d82826e990407364d5c829b73602a19ecdf7d0
> 0
> Starting server...
> Waiting for server log...
>
[15:00:24.430] >
> *
> * Reminder: You may only use this software with Visual Studio family products,
> * as described in the license (https://go.microsoft.com/fwlink/?linkid=2077057
)
> *
>
>
[15:00:24.466] > 58ca5e3a-8d30-4935-b67a-98422db7e04d==40480==36394=="centos"==
>
[15:00:24.718] "install" terminal command done
[15:00:24.719] Install terminal quit with output: 58ca5e3a-8d30-4935-b67a-98422db7e04d==40480==36394=="centos"==
[15:00:24.719] Received install output: 58ca5e3a-8d30-4935-b67a-98422db7e04d==40480==36394=="centos"==
[15:00:24.719] Failed to parse remote port from server output: 58ca5e3a-8d30-4935-b67a-98422db7e04d==40480==36394=="centos"==
[15:00:24.719]
[15:00:24.720] TELEMETRY: {"eventName":"resolver","properties":{"outcome":"failure","reason":"UnparsableOutput"},"measures":{"resolveAttempts":1,"retries":1}}
[15:00:24.721] ------
roblourens commented 5 years ago

Thanks @Dallas-Hays I will open a new issue for this part