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.67k stars 292 forks source link

ForwardAgent not working in Remote-SSH but locally #6735

Closed lcmgh closed 1 year ago

lcmgh commented 2 years ago
[09:05:03.401] Log Level: 1
[09:05:03.403] remote-ssh@0.81.2022051115
[09:05:03.403] win32 x64
[09:05:03.445] SSH Resolver called for "ssh-remote+7b22686f73744e616d65223a224f70656e537461636b227d", attempt 1
[09:05:03.446] "remote.SSH.useLocalServer": true
[09:05:03.446] "remote.SSH.path": C:\Windows\System32\OpenSSH\ssh.exe
[09:05:03.446] "remote.SSH.configFile": C:\Users\censored\.ssh\config
[09:05:03.446] "remote.SSH.useFlock": true
[09:05:03.446] "remote.SSH.lockfilesInTmp": false
[09:05:03.447] "remote.SSH.localServerDownload": auto
[09:05:03.447] "remote.SSH.remoteServerListenOnSocket": false
[09:05:03.447] "remote.SSH.showLoginTerminal": true
[09:05:03.447] "remote.SSH.defaultExtensions": []
[09:05:03.447] "remote.SSH.loglevel": 1
[09:05:03.447] "remote.SSH.enableDynamicForwarding": true
[09:05:03.448] "remote.SSH.enableRemoteCommand": false
[09:05:03.448] "remote.SSH.serverPickPortsFromRange": {}
[09:05:03.448] "remote.SSH.serverInstallPath": {}
[09:05:03.460] SSH Resolver called for host: OpenStack
[09:05:03.460] Setting up SSH remote "OpenStack"
[09:05:03.466] Acquiring local install lock: C:\Users\censored\AppData\Local\Temp\vscode-remote-ssh-14976783-install.lock
[09:05:03.474] Looking for existing server data file at c:\Users\censored\AppData\Roaming\Code\User\globalStorage\ms-vscode-remote.remote-ssh\vscode-ssh-host-14976783-c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5-0.81.2022051115\data.json
[09:05:03.475] Using commit id "c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5" and quality "stable" for server
[09:05:03.479] Install and start server if needed
[09:05:03.485] Checking ssh with "C:\Windows\System32\OpenSSH\ssh.exe -V"
[09:05:03.717] > OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2

[09:05:03.727] Using SSH config file "C:\Users\censored\.ssh\config"
[09:05:03.729] askpass server listening on \\.\pipe\vscode-ssh-askpass-41fc83d78493b3d213413eae4b18dc14674d5c2e-sock
[09:05:03.730] Spawning local server with {"serverId":1,"ipcHandlePath":"\\\\.\\pipe\\vscode-ssh-askpass-6c7b6711f5e842b43791a36011ba4bb2de880ae1-sock","sshCommand":"C:\\Windows\\System32\\OpenSSH\\ssh.exe","sshArgs":["-v","-T","-D","50838","-F","C:\\Users\\censored\\.ssh\\config","OpenStack","bash"],"serverDataFolderName":".vscode-server","dataFilePath":"c:\\Users\\censored\\AppData\\Roaming\\Code\\User\\globalStorage\\ms-vscode-remote.remote-ssh\\vscode-ssh-host-14976783-c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5-0.81.2022051115\\data.json"}
[09:05:03.730] Local server env: {"DISPLAY":"1","ELECTRON_RUN_AS_NODE":"1","SSH_ASKPASS":"c:\\Users\\censored\\.vscode\\extensions\\ms-vscode-remote.remote-ssh-0.81.2022051115\\out\\local-server\\askpass.bat","VSCODE_SSH_ASKPASS_NODE":"C:\\Users\\censored\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe","VSCODE_SSH_ASKPASS_EXTRA_ARGS":"--ms-enable-electron-run-as-node","VSCODE_SSH_ASKPASS_MAIN":"c:\\Users\\censored\\.vscode\\extensions\\ms-vscode-remote.remote-ssh-0.81.2022051115\\out\\askpass-main.js","VSCODE_SSH_ASKPASS_HANDLE":"\\\\.\\pipe\\vscode-ssh-askpass-41fc83d78493b3d213413eae4b18dc14674d5c2e-sock"}
[09:05:03.748] Spawned 13984
[09:05:03.926] > local-server-1> Spawned ssh, pid=10656
[09:05:04.052] stderr> OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2
[09:05:04.053] stderr> debug1: Reading configuration data C:\\Users\\censored\\.ssh\\config
[09:05:04.053] stderr> debug1: C:\\Users\\censored\\.ssh\\config line 1: Applying options for OpenStack
[09:05:04.067] stderr> debug1: Connecting to OpenStack [10.xx.xx.xx] port 22.
[09:05:04.074] stderr> debug1: Connection established.
[09:05:04.108] stderr> debug1: identity file C:\\.ssh\\id_rsa type 0
[09:05:04.115] stderr> debug1: identity file C:\\.ssh\\id_rsa-cert type -1
[09:05:04.116] stderr> debug1: Local version string SSH-2.0-OpenSSH_for_Windows_8.1
[09:05:04.117] stderr> debug1: Remote protocol version 2.0, remote software version OpenSSH_8.2p1 Ubuntu-4ubuntu0.5
[09:05:04.117] stderr> debug1: match: OpenSSH_8.2p1 Ubuntu-4ubuntu0.5 pat OpenSSH* compat 0x04000000
[09:05:04.118] stderr> debug1: Authenticating to 10.xx.xx.xx:22 as 'runner'
[09:05:04.120] stderr> debug1: SSH2_MSG_KEXINIT sent
[09:05:04.120] stderr> debug1: SSH2_MSG_KEXINIT received
[09:05:04.120] stderr> debug1: kex: algorithm: curve25519-sha256
[09:05:04.121] stderr> debug1: kex: host key algorithm: ecdsa-sha2-nistp256
[09:05:04.121] stderr> debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
[09:05:04.121] stderr> debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
[09:05:04.123] stderr> debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
[09:05:04.131] stderr> debug1: Server host key: ecdsa-sha2-nistp256 SHA256:kd8xyTvnW9uUjlFTM2zPtfRyfy2AAv4nFd+jZoBXhVA
[09:05:04.134] stderr> debug1: Host '10.xx.xx.xx' is known and matches the ECDSA host key.
[09:05:04.134] stderr> debug1: Found key in C:\\Users\\censored/.ssh/known_hosts:1
[09:05:04.137] stderr> debug1: rekey out after 134217728 blocks
[09:05:04.138] stderr> debug1: SSH2_MSG_NEWKEYS sent
[09:05:04.138] stderr> debug1: expecting SSH2_MSG_NEWKEYS
[09:05:04.138] stderr> debug1: SSH2_MSG_NEWKEYS received
[09:05:04.139] stderr> debug1: rekey in after 134217728 blocks
[09:05:04.139] stderr> debug1: pubkey_prepare: ssh_get_authentication_socket: No such file or directory
[09:05:04.139] stderr> debug1: Will attempt key: C:\\.ssh\\id_rsa RSA SHA256:crqPDbJXs0yA7CvKmGeRc0syd4Nrn4UG6C8qeepyyJw explicit
[09:05:04.140] stderr> debug1: SSH2_MSG_EXT_INFO received
[09:05:04.140] stderr> debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,sk-ssh-ed25519@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com>
[09:05:04.143] stderr> debug1: SSH2_MSG_SERVICE_ACCEPT received
[09:05:04.155] stderr> debug1: Authentications that can continue: publickey,password
[09:05:04.156] stderr> debug1: Next authentication method: publickey
[09:05:04.156] stderr> debug1: Offering public key: C:\\.ssh\\id_rsa RSA SHA256:crqPDbJXs0yA7CvKmGeRc0syd4Nrn4UG6C8qeepyyJw explicit
[09:05:04.161] stderr> debug1: Server accepts key: C:\\.ssh\\id_rsa RSA SHA256:crqPDbJXs0yA7CvKmGeRc0syd4Nrn4UG6C8qeepyyJw explicit
[09:05:04.313] stderr> debug1: Authentication succeeded (publickey).
[09:05:04.313] stderr> Authenticated to 10.xx.xx.xx ([10.xx.xx.xx]:22).
[09:05:04.314] stderr> debug1: Local connections to LOCALHOST:50838 forwarded to remote address socks:0
[09:05:04.315] stderr> debug1: Local forwarding listening on ::1 port 50838.
[09:05:04.315] stderr> debug1: channel 0: new [port listener]
[09:05:04.315] stderr> debug1: Local forwarding listening on 127.0.0.1 port 50838.
[09:05:04.316] stderr> debug1: channel 1: new [port listener]
[09:05:04.316] stderr> debug1: channel 2: new [client-session]
[09:05:04.317] stderr> debug1: Requesting no-more-sessions@openssh.com
[09:05:04.317] stderr> debug1: Entering interactive session.
[09:05:04.317] stderr> debug1: pledge: network
[09:05:04.607] stderr> debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
[09:05:04.608] stderr> debug1: Remote: /home/runner/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
[09:05:04.651] stderr> debug1: Remote: /home/runner/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
[09:05:04.652] stderr> debug1: ssh_get_authentication_socket: No such file or directory
[09:05:04.654] stderr> debug1: Sending command: bash
[09:05:04.666] > ready: 04551568ac38
[09:05:04.674] > Linux 5.4.0-110-generic #124-Ubuntu SMP Thu Apr 14 19:46:19 UTC 2022
[09:05:04.675] Platform: linux
[09:05:04.682] > /bin/bash
[09:05:04.683] Shell: bash
[09:05:04.683] Creating bash subshell inside "bash"
[09:05:04.691] > bash version:  5.0.17(1)-release
[09:05:04.706] > 04551568ac38: running
[09:05:04.723] > Acquiring lock on /home/runner/.vscode-server/bin/c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5/vscode-remote-lock.runner.c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5
[09:05:04.726] > Found existing installation at /home/runner/.vscode-server/bin/c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5...
[09:05:04.727] > Checking /home/runner/.vscode-server/.c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5.log and /home/runner/.vscode-server/.c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5.pid for a running server
> Looking for server with pid: 4802
[09:05:04.735] > Found running server...
[09:05:04.735] >  
> *
> * Reminder: You may only use this software with Visual Studio family products,
> * as described in the license (https://go.microsoft.com/fwlink/?linkid=2077057)
> *
>  
[09:05:04.741] > Checking server status on port 34709 with wget
[09:05:04.749] > 04551568ac38: start
> SSH_AUTH_SOCK====
> DISPLAY====
[09:05:04.751] > webUiAccessToken====
> listeningOn==34709==
> osReleaseId==ubuntu==
> arch==x86_64==
> tmpDir==/run/user/1000==
> platform==linux==
> unpackResult====
> didLocalDownload==0==
> downloadTime====
> installTime====
> extInstallTime====
> serverStartTime====
> connectionToken==1a111aa1-1a11-11a1-1a11-1a1111111111==
> 04551568ac38: end
[09:05:04.752] Received install output: 
SSH_AUTH_SOCK====
DISPLAY====webUiAccessToken====
listeningOn==34709==
osReleaseId==ubuntu==
arch==x86_64==
tmpDir==/run/user/1000==
platform==linux==
unpackResult====
didLocalDownload==0==
downloadTime====
installTime====
extInstallTime====
serverStartTime====
connectionToken==1a111aa1-1a11-11a1-1a11-1a1111111111==

[09:05:04.753] Remote server is listening on 34709
[09:05:04.754] Parsed server configuration: {"serverConfiguration":{"remoteListeningOn":{"port":34709},"osReleaseId":"ubuntu","arch":"x86_64","webUiAccessToken":"","sshAuthSock":"","display":"","tmpDir":"/run/user/1000","platform":"linux","connectionToken":"1a111aa1-1a11-11a1-1a11-1a1111111111"},"installUnpackCode":""}
[09:05:04.758] Persisting server connection details to c:\Users\censored\AppData\Roaming\Code\User\globalStorage\ms-vscode-remote.remote-ssh\vscode-ssh-host-14976783-c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5-0.81.2022051115\data.json
[09:05:04.768] Starting forwarding server. localPort 50841 -> socksPort 50838 -> remotePort 34709
[09:05:04.770] Forwarding server listening on 50841
[09:05:04.770] Waiting for ssh tunnel to be ready
[09:05:04.775] [Forwarding server 50841] Got connection 0
[09:05:04.780] Tunneled 34709 to local port 50841
[09:05:04.781] Resolved "ssh-remote+7b22686f73744e616d65223a224f70656e537461636b227d" to "127.0.0.1:50841"
[09:05:04.781] Updating terminal environments: {}
[09:05:04.789] TELEMETRY: {"eventName":"resolver","properties":{"osReleaseId":"ubuntu","arch":"x86_64","askedPw":"0","askedPassphrase":"0","asked2fa":"0","askedHostKey":"0","remoteInConfigFile":"1","gotUnrecognizedPrompt":"0","dynamicForwarding":"1","localServer":"1","didLocalDownload":"0","installUnpackCode":"0","outcome":"success"},"measures":{"resolveAttempts":1,"retries":1,"timing.totalResolveTime":1344,"timing.preSshTime":285,"timing.establishSshTime":976,"timing.scriptTime":1024}}
[09:05:04.794] ------

[09:05:04.808] [Forwarding server 50841] Got connection 1
[09:05:04.836] [Forwarding server 50841] Got connection 2
[09:05:07.498] TELEMETRY: {"eventName":"extraInfo","properties":{"remoteCloud":"aws"},"measures":{}}

SSH Config:

Host OpenStack
  HostName 10.xx.xx.xx
  User runner
  IdentityFile C:\.ssh\id_rsa
  ForwardAgent yes

ForwardAgent works fine when I connect manually to the server and clone a git repository that my local ssh client has access to. ssh runner@10.xx.xx.xx -A -i C:\.ssh\id_rsa -A

When connecting with the extension and cloning the repo it fails with public denied. I can also confirm that by establishing the connection with the extension and cloning from a connected terminal it fails with same error. That leads to the conclusion that the ForwardAgent is somehow when connection with vscode remote-ssh.

runner@remote-dev-0:~$ echo $SSH_AUTH_SOCK -> Empty output

Steps to Reproduce:

  1. Add config as above
  2. Connect to host via Remote SSH Plugin
  3. Clone git repo local instance has access to via integrated git clone function or manually via remote terminal -> Permission denied

Does this issue occur when you try this locally?: No Does this issue occur when you try this locally and all extensions are disabled?: No

bamurtaugh commented 2 years ago

Thanks for opening. So ForwardAgent works fine when I connect manually to the server and clone a git repository that my local ssh client has access to means you're able to clone this repo in an external terminal via SSH, not using VS Code or Remote-SSH?

cc @tanhakabir

tanhakabir commented 2 years ago

Just to verify what do you see when you connect to your remote with the following? (this is the ssh command we use for connection)

ssh -v -T -D 50838 -F C:\\Users\\censored\\.ssh\\config OpenStack bash

Are you able to properly git pull

lcmgh commented 2 years ago

Thanks for opening. So ForwardAgent works fine when I connect manually to the server and clone a git repository that my local ssh client has access to means you're able to clone this repo in an external terminal via SSH, not using VS Code or Remote-SSH?

cc @tanhakabir

Exactly. Key forwarding works fine when the connection is established from external terminals via ssh runner@10.xx.xx.xx -A -i C:\.ssh\id_rsa -A but not from the vscode spawned ssh connections.

Just to verify what do you see when you connect to your remote with the following? (this is the ssh command we use for connection)

$ ssh -v -T -D 50838 -F C:\\Users\\censored\\.ssh\\config Openstack bash
OpenSSH_7.7p1, OpenSSL 1.0.2o  27 Mar 2018
debug1: Reading configuration data C:\\Users\\censored\\.ssh\\config
debug1: C:\\Users\\censored\\.ssh\\config line 1: Applying options for Openstack
debug1: Connecting to 10.xx.xx.xx [10.xx.xx.xx] port 22.
debug1: Connection established.
debug1: identity file U:\\.ssh\\id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file U:\\.ssh\\id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.7
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.2p1 Ubuntu-4ubuntu0.5
debug1: match: OpenSSH_8.2p1 Ubuntu-4ubuntu0.5 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 10.xx.xx.xx:22 as 'runner'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:xwZQn61wU0CA6YJryxop2hUdF5x0Nfzh3gvXpA9Davg
debug1: Host '10.xx.xx.xx' is known and matches the ECDSA host key.
debug1: Found key in /u/.ssh/known_hosts:2
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,sk-ssh-ed25519@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:crqPDbJXs0yA7CvKmGeRc0syd4Nrn4UG6C8qeepyyJw U:\\.ssh\\id_rsa
debug1: Server accepts key: pkalg rsa-sha2-512 blen 535
debug1: Authentication succeeded (publickey).
Authenticated to 10.xx.xx.xx ([10.xx.xx.xx]:22).
debug1: Local connections to LOCALHOST:50838 forwarded to remote address socks:0
debug1: Local forwarding listening on ::1 port 50838.
debug1: channel 0: new [port listener]
debug1: Local forwarding listening on 127.0.0.1 port 50838.
debug1: channel 1: new [port listener]
debug1: channel 2: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
debug1: Remote: /home/runner/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug1: Remote: /home/runner/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug1: Requesting authentication agent forwarding.
debug1: Sending command: bash

Are you able to properly git pull

How do I connect to that shell? These commands did not work:

$ ssh localhost -p 50838 -v -i /u/.ssh/id_rsa
OpenSSH_7.7p1, OpenSSL 1.0.2o  27 Mar 2018
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to localhost [::1] port 50838.
debug1: Connection established.
debug1: identity file /u/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file /u/.ssh/id_rsa type -1
debug1: Local version string SSH-2.0-OpenSSH_7.7
ssh_exchange_identification: Connection closed by remote host
$ ssh localhost -p 50838 -v
OpenSSH_7.7p1, OpenSSL 1.0.2o  27 Mar 2018
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to localhost [::1] port 50838.
debug1: Connection established.
debug1: identity file /u/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file /u/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /u/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /u/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /u/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /u/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /u/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /u/.ssh/id_ed25519-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /u/.ssh/id_xmss type -1
debug1: key_load_public: No such file or directory
debug1: identity file /u/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.7
ssh_exchange_identification: Connection closed by remote host
tanhakabir commented 2 years ago

Hm we need to get the ssh connection command ssh -v -T -D 50838 -F C:\\Users\\censored\\.ssh\\config OpenStack bash to work or understand why it doesn't in terminal since this is what the extension uses to establish connection.

In your first set of logs what happened after you saw debug1: Sending command: bash? Was there any more logs?

lcmgh commented 2 years ago

These were the full logs.

Previous commands were executed in Git Bash. I now executed ssh -v -T -D 50838 -F C:\\Users\\censored\\.ssh\\config OpenStack bash with Powershell and we got different output. Note debug1: ssh_get_authentication_socket: No such file or directory at the end of the log.

PS U:\> ssh -v -T -D 50838 -F C:\\Users\\censored\\.ssh\\config Openstack bash
OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2
debug1: Reading configuration data C:\\\\Users\\\\censored\\\\.ssh\\\\config
debug1: C:\\\\Users\\\\censored\\\\.ssh\\\\config line 1: Applying options for Openstack
debug1: Connecting to Openstack [10.31.25.236] port 22.
debug1: Connection established.
debug1: identity file U:\\.ssh\\id_rsa type 0
debug1: identity file U:\\.ssh\\id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_8.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.2p1 Ubuntu-4ubuntu0.5
debug1: match: OpenSSH_8.2p1 Ubuntu-4ubuntu0.5 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 10.31.25.236:22 as 'runner'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:xwZQn61wU0CA6YJryxop2hUdF5x0Nfzh3gvXpA9Davg
debug1: read_passphrase: can't open /dev/tty: No such file or directory
The authenticity of host '10.31.25.236 (10.31.25.236)' can't be established.
ECDSA key fingerprint is SHA256:xwZQn61wU0CA6YJryxop2hUdF5x0Nfzh3gvXpA9Davg.
Are you sure you want to continue connecting (yes/no/[fingerprint])? y
debug1: read_passphrase: can't open /dev/tty: No such file or directory
Please type 'yes', 'no' or the fingerprint: yes
Warning: Permanently added '10.31.25.236' (ECDSA) to the list of known hosts.
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: pubkey_prepare: ssh_get_authentication_socket: No such file or directory
debug1: Will attempt key: U:\\.ssh\\id_rsa RSA SHA256:crqPDbJXs0yA7CvKmGeRc0syd4Nrn4UG6C8qeepyyJw explicit
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,sk-ssh-ed25519@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering public key: U:\\.ssh\\id_rsa RSA SHA256:crqPDbJXs0yA7CvKmGeRc0syd4Nrn4UG6C8qeepyyJw explicit
debug1: Server accepts key: U:\\.ssh\\id_rsa RSA SHA256:crqPDbJXs0yA7CvKmGeRc0syd4Nrn4UG6C8qeepyyJw explicit
debug1: Authentication succeeded (publickey).
Authenticated to 10.31.25.236 ([10.31.25.236]:22).
debug1: Local connections to LOCALHOST:50838 forwarded to remote address socks:0
debug1: Local forwarding listening on ::1 port 50838.
bind [::1]:50838: Permission denied
debug1: Local forwarding listening on 127.0.0.1 port 50838.
bind [127.0.0.1]:50838: Permission denied
channel_setup_fwd_listener_tcpip: cannot listen to port: 50838
Could not request local forwarding.
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
debug1: Remote: /home/runner/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug1: Remote: /home/runner/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug1: ssh_get_authentication_socket: No such file or directory
debug1: Sending command: bash
tanhakabir commented 2 years ago

So Remote-SSH actually uses Powershell to execute any connection commands, not other bash shells you may have installed on your machine. These logs look more in line with the errors we were seeing in VS Code.

It looks like we're having issues binding to a port for local forwarding:

debug1: Local forwarding listening on 127.0.0.1 port 50838.
bind [127.0.0.1]:50838: Permission denied
channel_setup_fwd_listener_tcpip: cannot listen to port: 50838
Could not request local forwarding.

Do you have an idea why you might not have permissions to bind to another port on your machine?

lcmgh commented 2 years ago

I once had an issue to bind port 9090 and read somewhere that certain ranges are blocked for non-admins on Windows. But cannot find the exact statement again.

Just found a way to see if certain ports are blocked by Hyper-V. But 50838 is not within the ranges.

PS U:\> netsh interface ipv4 show excludedportrange protocol=tcp                                                        
Portausschlussbereiche für das Protokoll "tcp"

Startport      Endport
----------    --------
        80          80
      4242        4242
      5985        5985
      6064        6064
      6065        6065
      9000        9000
      9001        9001
      9013        9013
     47001       47001
     50000       50059     *

* - Verwaltete Portausschlüsse.
PS U:\> netsh int ipv4 show dynamicport tcp

Protokoll tcp Dynamischer Portbereich
---------------------------------
Startport      : 49152 (Start port)
Anzahl von Ports : 16384 (Number of ports)

Any hints for debugging?

wolrah commented 2 years ago

For what it's worth I found this report while trying to troubleshoot my own problem with SSH -D forwarding not working just from the command line in general. I get the same "permission denied, cannot listen to port" error intermittently and when it starts happening that feature doesn't work until a reboot.

That seems like a strong indicator that this issue is not directly in this project but instead some problem with the SSH client Windows provides that just happens to impact this extension.

roblourens commented 1 year ago

You can set the remote.SSH.path setting to your git bash ssh if it works using that instead