jeanp413 / open-remote-ssh

VSCode Remote Development: Open any folder on a remote machine using SSH.
MIT License
309 stars 43 forks source link

VSCodium macOS cannot connect using public key #90

Closed Dekker1 closed 1 year ago

Dekker1 commented 1 year ago

I'm using VSCodium on an M1 macOS system. I recently switched from VS Code, and use the MS extension. (I was really grateful to see an open alternative. Thank you for the hard work!) I have various servers to which I connect with SSH using public key authentication, but I cannot get it to work using this extension. When I try to connect I am prompted by the following message.

Screenshot 2023-05-15 at 13 44 32

I don't know which password it is asking for, but when I enter the password for the account on the server I get re-prompted, so I assume this is not the one. My public key does not have a password, but leaving it blank results in an error Could not establish connection to "<server>" and the following messages are displayed in the output.

[Info  - 03:54:07.151] Resolving ssh remote authority 'ssh-remote+<server>' (attemp #1)
[Trace  - 03:54:07.162] Identity keys:
/Users/<user>/.ssh/id_ed25519 ssh-ed25519 SHA256:<sig>
[Info  - 03:54:09.80] Trying no-auth authentication
[Info  - 03:54:09.391] Trying publickey authentication: /Users/dekker1/.ssh/id_ed25519 ssh-ed25519 SHA256:<sig>
[Error  - 03:54:11.591] Error resolving authority
Error: All configured authentication methods failed
    at Ae (/Users/<user>/.vscode-oss/extensions/jeanp413.open-remote-ssh-0.0.36-universal/out/extension.js:1:152215)
    at /Users/<user>/.vscode-oss/extensions/jeanp413.open-remote-ssh-0.0.36-universal/out/extension.js:1:391821
    at authHandler (/Users/<user>/.vscode-oss/extensions/jeanp413.open-remote-ssh-0.0.36-universal/out/extension.js:1:387435)
    at me (/Users/dekker1/.vscode-oss/extensions/jeanp413.open-remote-ssh-0.0.36-universal/out/extension.js:1:155088)
    at process.processTicksAndRejections (node:internal/process/task_queues:78:11)

Am I doing something wrong, or am I trying to use something that isn't supported? (maybe ed25519 keys, or keys without passwords?)

jeanp413 commented 1 year ago

@Dekker1 it supports both ed25519 keys and passwordless keys, and I'm using them both :thinking:. could you try first deleting your key from the ssh-agent with ssh-add -D and then adding it back ssh-add ~/.ssh/id_ed25519 and see if it ask for the passphrase or not

Dekker1 commented 1 year ago

I managed to resolve the issue. I tried your suggestions, using ssh-add I was prompted for a password, but leaving it empty worked. Then I was reminded that this might be because the password was stored somewhere. I found that in my .ssh/config I had set `UseKeychain yes, and the password was stored in the macOS key chain. It seems that the VSCode extension (and the local ssh installation) that I used previously, must have abided by this option and used the system stored password. (It apparently had been so long that I had even forgotten I still had a password).

It would be great if this extension could support the UseKeychain option.

jeanp413 commented 1 year ago

@Dekker1 Just tested this and for me it's working as expected and reading the key from the agent, I forgot to mention you need to pass --apple-use-keychain so the correct command is ssh-add --apple-use-keychain ~/.ssh/id_ed25519, I don't have UseKeychain yes in my config Let me know if it's working after you use the updated command

Dekker1 commented 1 year ago

Great! That fully solves my issue. Thank you for the amazing support!