Forums

SSH via VS Code problems

Hi, I get this when trying to connect via SSH using VS Code and not able to connect, but am able connect just fine via Terminal using ssh username@ssh.pythonanywhere.com (I have private and public key setup)

[09:45:30.805] Log Level: 2 [09:45:30.810] SSH Resolver called for "ssh-remote+ssh.pythonanywhere.com", attempt 1 [09:45:30.810] "remote.SSH.useLocalServer": true [09:45:30.810] "remote.SSH.useExecServer": true [09:45:30.810] "remote.SSH.path": undefined [09:45:30.810] "remote.SSH.configFile": /Users/pablorendon/.ssh/config [09:45:30.810] "remote.SSH.useFlock": true [09:45:30.810] "remote.SSH.lockfilesInTmp": false [09:45:30.810] "remote.SSH.localServerDownload": auto [09:45:30.810] "remote.SSH.remoteServerListenOnSocket": false [09:45:30.810] "remote.SSH.showLoginTerminal": false [09:45:30.810] "remote.SSH.defaultExtensions": [] [09:45:30.810] "remote.SSH.loglevel": 2 [09:45:30.810] "remote.SSH.enableDynamicForwarding": true [09:45:30.810] "remote.SSH.enableRemoteCommand": false [09:45:30.810] "remote.SSH.serverPickPortsFromRange": {} [09:45:30.810] "remote.SSH.serverInstallPath": {} [09:45:30.812] VS Code version: 1.87.2 [09:45:30.812] Remote-SSH version: remote-ssh@0.109.0 [09:45:30.812] darwin arm64 [09:45:30.812] SSH Resolver called for host: ssh.pythonanywhere.com [09:45:30.812] Setting up SSH remote "ssh.pythonanywhere.com" [09:45:30.814] Acquiring local install lock: /var/folders/6g/h08_8rjd5rqcr1t8nt6c2kbc0000gn/T/vscode-remote-ssh-d77b5fc5-install.lock [09:45:30.814] Looking for existing server data file at /Users/pablorendon/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-ssh/vscode-ssh-host-d77b5fc5-863d2581ecda6849923a2118d93a088b0745d9d6-0.109.0-es/data.json [09:45:30.815] Using commit id "863d2581ecda6849923a2118d93a088b0745d9d6" and quality "stable" for server [09:45:30.817] Install and start server if needed [09:45:30.819] PATH: /opt/anaconda3/bin:/opt/anaconda3/condabin:/opt/homebrew/bin:/opt/homebrew/sbin:/Library/Frameworks/Python.framework/Versions/3.11/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin [09:45:30.819] Checking ssh with "ssh -V" [09:45:30.822] > OpenSSH_9.0p1, LibreSSL 3.3.6

[09:45:30.823] Using SSH config file "/Users/pablorendon/.ssh/config" [09:45:30.823] askpass server listening on /var/folders/6g/h08_8rjd5rqcr1t8nt6c2kbc0000gn/T/vscode-ssh-askpass-8b43b1b08d0be6631a74bc08c8f4c7c8fe8235da.sock [09:45:30.823] Spawning local server with {"serverId":1,"ipcHandlePath":"/var/folders/6g/h08_8rjd5rqcr1t8nt6c2kbc0000gn/T/vscode-ssh-askpass-5c052c49e4e8059a9d8a96350cdfd3201c901492.sock","sshCommand":"ssh","sshArgs":["-v","-T","-D","50954","-o","ConnectTimeout=15","-F","/Users/pablorendon/.ssh/config","ssh.pythonanywhere.com"],"serverDataFolderName":".vscode-server","dataFilePath":"/Users/pablorendon/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-ssh/vscode-ssh-host-d77b5fc5-863d2581ecda6849923a2118d93a088b0745d9d6-0.109.0-es/data.json"} [09:45:30.823] Local server env: {"SSH_AUTH_SOCK":"/private/tmp/com.apple.launchd.NF7pnbEjLl/Listeners","SHELL":"/bin/zsh","DISPLAY":"1","ELECTRON_RUN_AS_NODE":"1","SSH_ASKPASS":"/Users/pablorendon/.vscode/extensions/ms-vscode-remote.remote-ssh-0.109.0/out/local-server/askpass.sh","VSCODE_SSH_ASKPASS_NODE":"/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin)","VSCODE_SSH_ASKPASS_EXTRA_ARGS":"","VSCODE_SSH_ASKPASS_MAIN":"/Users/pablorendon/.vscode/extensions/ms-vscode-remote.remote-ssh-0.109.0/out/askpass-main.js","VSCODE_SSH_ASKPASS_HANDLE":"/var/folders/6g/h08_8rjd5rqcr1t8nt6c2kbc0000gn/T/vscode-ssh-askpass-8b43b1b08d0be6631a74bc08c8f4c7c8fe8235da.sock"} [09:45:30.824] Spawned 92590 [09:45:30.912] > local-server-1> Running ssh connection command: ssh -v -T -D 50954 -o ConnectTimeout=15 -F /Users/pablorendon/.ssh/config ssh.pythonanywhere.com [09:45:30.913] > local-server-1> Spawned ssh, pid=92599 [09:45:30.915] stderr> OpenSSH_9.0p1, LibreSSL 3.3.6 [09:45:31.554] stderr> debug1: Server host key: ssh-rsa SHA256:zy2jmqxNg/fs6tFZK55OjHTI3B2UofzOiUvTPtcX3/Y [09:45:31.978] stderr> <<<<<<:>~ PythonAnywhere SSH. Help @ https://help.pythonanywhere.com/pages/SSHAccess [09:45:32.266] stderr> Authenticated to ssh.pythonanywhere.com ([23.21.200.247]:22) using "publickey". [09:45:34.087] > ready: 63c451d3b7db [09:45:34.213] > Linux 5.15.0-1044-aws #49~20.04.1-Ubuntu SMP Mon Aug 21 17:09:32 UTC 2023 [09:45:34.214] Platform: linux [09:45:34.338] > /bin/bash [09:45:34.339] Shell: bash [09:45:34.339] Creating bash subshell inside "bash" [09:45:34.466] > bash version: 5.0.17(1)-release [09:45:34.516] > bash version: 5.0.17(1)-release [09:45:34.572] > bash version: 5.0.17(1)-release [09:45:34.601] > 63c451d3b7db: running [09:45:34.612] > Found existing installation at /home/pablorendon/.vscode-server...

Starting VS Code CLI... "/home/pablorendon/.vscode-server/code-863d2581ecda6849923a2118d93a088b0745d9d6" command-shell --cli-data-dir "/home/pablorendon/.vscode-server/cli" --on-port --parent-process-id 3665312 &> "/home/pablorendon/.vscode-server/.cli.863d2581ecda6849923a2118d93a088b0745d9d6.log" < /dev/null printenv: [09:45:34.612] > SHELL=/bin/bash HISTCONTROL=ignoreboth PWD=/home/pablorendon LOGNAME=pablorendon MOTD_SHOWN=pam VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh HOME=/home/pablorendon USERNAME=pablorendon LANG=C.UTF-8 VIRTUALENVWRAPPER_WORKON_CD=1 VSCODE_AGENT_FOLDER=/home/pablorendon/.vscode-server SSH_CONNECTION=66.75.80.224 50955 10.0.5.0 22 WORKON_HOME=/home/pablorendon/.virtualenvs USER=pablorendon VIRTUALENVWRAPPER_PROJECT_FILENAME=.project SHLVL=1 SSH_CLIENT=66.75.80.224 50955 22 PATH=/home/pablorendon/.local/bin:/usr/local/julia-1.6.1/bin:/usr/lib/postgresql/12/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin VIRTUALENVWRAPPER_HOOK_DIR=/home/pablorendon/.virtualenvs _=/usr/bin/printenv [09:45:34.614] > Removing old logfile at /home/pablorendon/.vscode-server/.cli.863d2581ecda6849923a2118d93a088b0745d9d6.log [09:45:34.618] > Spawned remote CLI: 3665336 [09:45:34.623] > Exec server process not found [09:45:34.624] stderr> Error, do this: mount -t proc proc /proc [09:45:34.638] > 63c451d3b7db: start DISPLAY==== listeningOn==== osReleaseId==ubuntu== arch==x86_64== vscodeArch==x64== bitness==64== tmpDir==/tmp== platform==linux== unpackResult==== didLocalDownload==0== downloadTime==== installTime==== serverStartTime==11== execServerToken==11111111-1a11-1a11-aa11-11a11aa1a111== 63c451d3b7db: end [09:45:34.639] Received install output: DISPLAY==== listeningOn==== osReleaseId==ubuntu== arch==x86_64== vscodeArch==x64== bitness==64== tmpDir==/tmp== platform==linux== unpackResult==== didLocalDownload==0== downloadTime==== installTime==== serverStartTime==11== execServerToken==11111111-1a11-1a11-aa11-11a11aa1a111==

[09:45:34.641] Failed to parse remote port from server output [09:45:34.641] Terminating local server [09:45:34.645] Resolver error: Error: at g.Create (/Users/pablorendon/.vscode/extensions/ms-vscode-remote.remote-ssh-0.109.0/out/extension.js:2:499734) at t.handleInstallOutput (/Users/pablorendon/.vscode/extensions/ms-vscode-remote.remote-ssh-0.109.0/out/extension.js:2:497056) at e (/Users/pablorendon/.vscode/extensions/ms-vscode-remote.remote-ssh-0.109.0/out/extension.js:2:558185) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async /Users/pablorendon/.vscode/extensions/ms-vscode-remote.remote-ssh-0.109.0/out/extension.js:2:580094 at async t.withShowDetailsEvent (/Users/pablorendon/.vscode/extensions/ms-vscode-remote.remote-ssh-0.109.0/out/extension.js:2:583753) at async /Users/pablorendon/.vscode/extensions/ms-vscode-remote.remote-ssh-0.109.0/out/extension.js:2:554890 at async T (/Users/pablorendon/.vscode/extensions/ms-vscode-remote.remote-ssh-0.109.0/out/extension.js:2:552941) at async t.resolveWithLocalServer (/Users/pablorendon/.vscode/extensions/ms-vscode-remote.remote-ssh-0.109.0/out/extension.js:2:554430) at async k (/Users/pablorendon/.vscode/extensions/ms-vscode-remote.remote-ssh-0.109.0/out/extension.js:2:577311) at async t.resolve (/Users/pablorendon/.vscode/extensions/ms-vscode-remote.remote-ssh-0.109.0/out/extension.js:2:581124) at async /Users/pablorendon/.vscode/extensions/ms-vscode-remote.remote-ssh-0.109.0/out/extension.js:2:847283 [09:45:34.651] ------

[09:45:34.655] Local server exit: 15

That would not work on PythonAnywhere currently. We plan to work on that.

Thanks for reply, but why does it work great sometimes and not at all other times?

That sounds very strange; in which cases does it work? From your original post I got the impression that regular ssh works fine, but that VS code always fails (which is what I would expect), but are you finding that VS code sometimes works?

That is correct. regular ssh works fine. SSH through VS Code used to work fine also many months ago. Now I am using it again and have run into this problem. It works fine (through VS code) and then it starts not to. two days ago I was on it through VS code all day and it was great. then ^ started happening again. So yes, it sometimes works now.

What would be steps to reproduce it?

  1. Deleted .vscode-server from /home/pablorendon
  2. downgraded Remote-SSH on VS Code to v0.107.2023090815
  3. tried to connect again and it works

So the older version of Remote-SSH works reliably?

Yes the older version works reliably!

That may then be something to raise with the authors of remote-SSH. They will have a better idea of the changes between the versions.

I can confirm this is an issue. Go to the Remote - SSH extension in VS Code. Click on the down arrow beside 'Uninstall'
Choose 'Install Another Version' and revert to 0.107.1 That's the last working version as of today.

I can confirm this as well. After struggling to SSH w/ VS Code I reverted to Remote - SSH extension 0.107.1 from 0.109.0 and I was successful in connecting

Many thanks for confirming that! It looks like the most recent versions have made some kind of change on the server side that isn't working on our service for some reason. From the logging output in the first post on this thread, it looks like it's writing some kind of logging to a file with a name like /home/YOURUSERNAME/.vscode-server/.cli.SOMERANDOMSTRING.log. If someone could post the contents of that file from a failed connection attempt, that would help us work out what the issue might be.

Same here. Downgrading Remote-SSH on VS Code to v0.107 works for me, too.

Excellent! Thanks for confirming :-)