devspace-sh / devspace

DevSpace - The Fastest Developer Tool for Kubernetes ⚡ Automate your deployment workflow with DevSpace and develop software directly inside Kubernetes.
https://devspace.sh
Apache License 2.0
4.29k stars 359 forks source link

Cannot connect to ssh server within Dev container: "no matching host key type found" #2420

Closed myspotontheweb closed 1 year ago

myspotontheweb commented 1 year ago

What happened?

I was attempting to run the Visual Studio demo

https://www.devspace.sh/docs/ide-integration/visual-studio-code#tldr

The following output was emitted in Visual Code

[18:07:00.313] Log Level: 2
[18:07:00.317] remote-ssh@0.92.0
[18:07:00.317] linux x64
[18:07:00.382] SSH Resolver called for "ssh-remote+my-app.devspace", attempt 1
[18:07:00.383] "remote.SSH.useLocalServer": true
[18:07:00.383] "remote.SSH.path": undefined
[18:07:00.384] "remote.SSH.configFile": undefined
[18:07:00.384] "remote.SSH.useFlock": true
[18:07:00.384] "remote.SSH.lockfilesInTmp": false
[18:07:00.384] "remote.SSH.localServerDownload": auto
[18:07:00.384] "remote.SSH.remoteServerListenOnSocket": false
[18:07:00.384] "remote.SSH.showLoginTerminal": false
[18:07:00.385] "remote.SSH.defaultExtensions": []
[18:07:00.385] "remote.SSH.loglevel": 2
[18:07:00.385] "remote.SSH.enableDynamicForwarding": true
[18:07:00.385] "remote.SSH.enableRemoteCommand": false
[18:07:00.386] "remote.SSH.serverPickPortsFromRange": {}
[18:07:00.386] "remote.SSH.serverInstallPath": {}
[18:07:00.390] SSH Resolver called for host: my-app.devspace
[18:07:00.390] Setting up SSH remote "my-app.devspace"
[18:07:00.393] Acquiring local install lock: /tmp/vscode-remote-ssh-830fe282-install.lock
[18:07:00.395] Looking for existing server data file at /home/mark/.config/Code/User/globalStorage/ms-vscode-remote.remote-ssh/vscode-ssh-host-830fe282-6261075646f055b99068d3688932416f2346dd3b-0.92.0/data.json
[18:07:00.395] Using commit id "6261075646f055b99068d3688932416f2346dd3b" and quality "stable" for server
[18:07:00.398] Install and start server if needed
[18:07:00.400] PATH: /home/mark/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/mark/.arkade/bin
[18:07:00.401] Checking ssh with "ssh -V"
[18:07:00.413] > OpenSSH_9.0p1 Ubuntu-1ubuntu7, OpenSSL 3.0.5 5 Jul 2022

[18:07:00.416] askpass server listening on /run/user/1000/vscode-ssh-askpass-1a8bc7dc310f347190d98ad2e0efccf6abb0b234.sock
[18:07:00.416] Spawning local server with {"serverId":1,"ipcHandlePath":"/run/user/1000/vscode-ssh-askpass-5d3ee3236e4d694a41359a1cc794011c6810bd11.sock","sshCommand":"ssh","sshArgs":["-v","-T","-D","46003","-o","ConnectTimeout=15","my-app.devspace"],"serverDataFolderName":".vscode-server","dataFilePath":"/home/mark/.config/Code/User/globalStorage/ms-vscode-remote.remote-ssh/vscode-ssh-host-830fe282-6261075646f055b99068d3688932416f2346dd3b-0.92.0/data.json"}
[18:07:00.416] Local server env: {"SSH_AUTH_SOCK":"/run/user/1000/keyring/ssh","SHELL":"/bin/bash","DISPLAY":":1","ELECTRON_RUN_AS_NODE":"1","SSH_ASKPASS":"/home/mark/.vscode/extensions/ms-vscode-remote.remote-ssh-0.92.0/out/local-server/askpass.sh","VSCODE_SSH_ASKPASS_NODE":"/usr/share/code/code","VSCODE_SSH_ASKPASS_EXTRA_ARGS":"--ms-enable-electron-run-as-node","VSCODE_SSH_ASKPASS_MAIN":"/home/mark/.vscode/extensions/ms-vscode-remote.remote-ssh-0.92.0/out/askpass-main.js","VSCODE_SSH_ASKPASS_HANDLE":"/run/user/1000/vscode-ssh-askpass-1a8bc7dc310f347190d98ad2e0efccf6abb0b234.sock"}
[18:07:00.423] Spawned 22365
[18:07:00.567] > local-server-1> Spawned ssh, pid=22374
[18:07:00.570] stderr> OpenSSH_9.0p1 Ubuntu-1ubuntu7, OpenSSL 3.0.5 5 Jul 2022
[18:07:00.581] stderr> Unable to negotiate with 127.0.0.1 port 10341: no matching host key type found. Their offer: ssh-rsa
[18:07:00.582] > local-server-1> ssh child died, shutting down
[18:07:00.589] Local server exit: 0
[18:07:00.589] Received install output: local-server-1> Spawned ssh, pid=22374
OpenSSH_9.0p1 Ubuntu-1ubuntu7, OpenSSL 3.0.5 5 Jul 2022
Unable to negotiate with 127.0.0.1 port 10341: no matching host key type found. Their offer: ssh-rsa
local-server-1> ssh child died, shutting down

[18:07:00.590] Failed to parse remote port from server output
[18:07:00.593] Resolver error: Error: 
    at g.Create (/home/mark/.vscode/extensions/ms-vscode-remote.remote-ssh-0.92.0/out/extension.js:1:583821)
    at t.handleInstallOutput (/home/mark/.vscode/extensions/ms-vscode-remote.remote-ssh-0.92.0/out/extension.js:1:582473)
    at Object.e [as tryInstallWithLocalServer] (/home/mark/.vscode/extensions/ms-vscode-remote.remote-ssh-0.92.0/out/extension.js:1:623084)
    at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async /home/mark/.vscode/extensions/ms-vscode-remote.remote-ssh-0.92.0/out/extension.js:1:642212
    at async t.withShowDetailsEvent (/home/mark/.vscode/extensions/ms-vscode-remote.remote-ssh-0.92.0/out/extension.js:1:645932)
    at async /home/mark/.vscode/extensions/ms-vscode-remote.remote-ssh-0.92.0/out/extension.js:1:621556
    at async T (/home/mark/.vscode/extensions/ms-vscode-remote.remote-ssh-0.92.0/out/extension.js:1:618062)
    at async t.resolveWithLocalServer (/home/mark/.vscode/extensions/ms-vscode-remote.remote-ssh-0.92.0/out/extension.js:1:621171)
    at async t.resolve (/home/mark/.vscode/extensions/ms-vscode-remote.remote-ssh-0.92.0/out/extension.js:1:643540)
    at async /home/mark/.vscode/extensions/ms-vscode-remote.remote-ssh-0.92.0/out/extension.js:1:722342
[18:07:00.598] ------

Specifically this line indicates a problem connecting the ssh server running within the container

[18:38:15.520] > local-server-1> Spawned ssh, pid=25714
[18:38:15.526] stderr> OpenSSH_9.0p1 Ubuntu-1ubuntu7, OpenSSL 3.0.5 5 Jul 2022
[18:38:15.541] stderr> Unable to negotiate with 127.0.0.1 port 11302: no matching host key type found. Their offer: ssh-rsa
[18:38:15.542] > local-server-1> ssh child died, shutting down

What did you expect to happen instead?

I expected so see coder connect via SSH without incident

How can we reproduce the bug? (as minimally and precisely as possible)

git clone https://github.com/loft-sh/devspace-vscode-example.git
cd devspace-vscode-example
devspace use namespace moc-test1
devspace dev

Local Environment:

Kubernetes Cluster:

Anything else we need to know?

$ code --version
1.73.1
6261075646f055b99068d3688932416f2346dd3b
x64

$ code --list-extensions
ms-vscode-remote.remote-ssh
ms-vscode-remote.remote-ssh-edit
ms-vscode.remote-explorer
myspotontheweb commented 1 year ago

Discovered a work-around.

Added "HostkeyAlgorithms" and "PubkeyAcceptedAlgorithms" configuration to the ssh configuration file generated by Devspace

$ cat ~/.ssh/config
# DevSpace Start my-app.devspace
Host my-app.devspace
  HostName localhost
  LogLevel error
  Port 10620
  IdentityFile /home/mark/.devspace/ssh/id_devspace_rsa
  StrictHostKeyChecking no
  UserKnownHostsFile /dev/null
  User devspace
  HostkeyAlgorithms +ssh-rsa         # Added
  PubkeyAcceptedAlgorithms +ssh-rsa  # Added
# DevSpace End my-app.devspace

It appears the sha-1 has been deprecated since OpenSSH v8.8

This release disables RSA signatures using the SHA-1 hash algorithm by default.

alexandradragodan commented 1 year ago

Hey, @myspotontheweb.

Thanks for reporting this issue! We really appreciate it! We are looking into it.

Are you satisfied with the workaround you have discovered? Thanks!

FabianKramm commented 1 year ago

We have updated our dependencies and this should be fixed with the next release of DevSpace