jeanp413 / open-remote-ssh

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

Error: Encrypted OpenSSH private key detected, but no passphrase given #154

Open rubirubsen opened 5 months ago

rubirubsen commented 5 months ago

/Error for me on vscodium, was putting my config as it should be

ctrl + shift + p => Remote-SSH: Open SSH configuration file... :

Host 207.xxx.xxx.25 HostName rxxxxxxt.de User root Port 22 IdentityFile C:\Users\rubix\Documents\Keys\rxxxxxxxt_private_ssh.key

on console it gives me this exact error:

[Info - 15:59:23.278] Resolving ssh remote authority 'ssh-remote+207.xxx.xxx.25' (attemp #1) [Error - 15:59:23.290] Error while parsing SSH public key C:\Users\rubix\Documents\Keys\rxxxxxxxt_private_ssh.key: Error: Encrypted OpenSSH private key detected, but no passphrase given at q.parse (c:\Users\rubix.vscode-oss\extensions\jeanp413.open-remote-ssh-0.0.45-universal\out\extension.js:1:358205) at Object.ee [as parseKey] (c:\Users\rubix.vscode-oss\extensions\jeanp413.open-remote-ssh-0.0.45-universal\out\extension.js:1:366752) at c:\Users\rubix.vscode-oss\extensions\jeanp413.open-remote-ssh-0.0.45-universal\out\extension.js:1:442957 at Array.map () at t.gatherIdentityFiles (c:\Users\rubix.vscode-oss\extensions\jeanp413.open-remote-ssh-0.0.45-universal\out\extension.js:1:442896) at async c:\Users\rubix.vscode-oss\extensions\jeanp413.open-remote-ssh-0.0.45-universal\out\extension.js:1:403197 [Trace - 15:59:23.301] Identity keys: None [Info - 15:59:23.513] Trying no-auth authentication [Error - 15:59:23.653] Error resolving authority Error: All configured authentication methods failed at me (c:\Users\rubix.vscode-oss\extensions\jeanp413.open-remote-ssh-0.0.45-universal\out\extension.js:1:155838) at c:\Users\rubix.vscode-oss\extensions\jeanp413.open-remote-ssh-0.0.45-universal\out\extension.js:1:409472 at authHandler (c:\Users\rubix.vscode-oss\extensions\jeanp413.open-remote-ssh-0.0.45-universal\out\extension.js:1:404849) at Se (c:\Users\rubix.vscode-oss\extensions\jeanp413.open-remote-ssh-0.0.45-universal\out\extension.js:1:159056) at USERAUTH_FAILURE (c:\Users\rubix.vscode-oss\extensions\jeanp413.open-remote-ssh-0.0.45-universal\out\extension.js:1:147859) at 51 (c:\Users\rubix.vscode-oss\extensions\jeanp413.open-remote-ssh-0.0.45-universal\out\extension.js:1:311872) at e.exports.M (c:\Users\rubix.vscode-oss\extensions\jeanp413.open-remote-ssh-0.0.45-universal\out\extension.js:1:178401) at H.decrypt (c:\Users\rubix.vscode-oss\extensions\jeanp413.open-remote-ssh-0.0.45-universal\out\extension.js:1:274737) at e.exports.F [as _parse] (c:\Users\rubix.vscode-oss\extensions\jeanp413.open-remote-ssh-0.0.45-universal\out\extension.js:1:177925) at e.exports.parse (c:\Users\rubix.vscode-oss\extensions\jeanp413.open-remote-ssh-0.0.45-universal\out\extension.js:1:182312) at Socket. (c:\Users\rubix.vscode-oss\extensions\jeanp413.open-remote-ssh-0.0.45-universal\out\extension.js:1:154578) at Socket.emit (node:events:514:28) at Socket.emit (node:domain:488:12) at addChunk (node:internal/streams/readable:376:12) at readableAddChunk (node:internal/streams/readable:349:9) at Readable.push (node:internal/streams/readable:286:10) at TCP.onStreamRead (node:internal/stream_base_commons:190:23)

Is this an error I produce or something I miss or is somebody else getting the same error? Or might somebody reveal to me how to putt the passphrase somewhere? I also do use putty and pageant if this helps in any way.

I also tried to figure out about my ssh agent by putting "Get-WmiObject win32service | ?{$.Name -like 'ssh-agent'} | select PathName" into PowerShell which showed up this:

PathName

C:\WINDOWS\System32\OpenSSH\ssh-agent.exe

May be this is also important to get some proper advice. I hope I provided all informations needed and anyone of you guys is able to give me the ultimate advice =)

Cheers

zhengliw commented 5 months ago

Also get this error on mac, not on fedora linux though... any updates?

edit: trying #32 out now

luckylinux commented 4 months ago

In my Case (Client: Ubuntu 24.04 Noble AMD64, Server: Debian 12 Bookworm AMD64) it just says:

[Trace  - 16:20:30.801] Identity keys: None
[Info  - 16:20:30.921] Trying no-auth authentication
[Info  - 16:20:30.971] Trying password authentication
[Error  - 16:21:30.808] Error resolving authority
Error: Timed out while waiting for handshake

And then proceeeds to ask for a Passphrase :-1:.

My ~/.ssh/config:

# Applies to ALL Hosts
Host *
    # This will prevent: Received Disconnect from XXX.XXX.XXX.XXX port XX: Too many Authentication Failures
    IdentitiesOnly=yes

# Include all Files from config.d SubFolder Ending with .config
Include config.d/*.config

Then I load a File from ~/.ssh/config.d/<HOST>.config.

I have a Password-Protected Private Key, however it has already been unlocked via ssh-add, so if I manually do ssh root@MYHOST it can connect without Issues.

So unfortunately the Extension is not behaving like the "normal" ssh Client Command.

luckylinux commented 4 months ago

Actually this seems to work (Settings -> Extensions -> Remote - SSH): image

Note that I listed ALL Files in the ~/.ssh/config.d/ Folder (~/.ssh/config.d/*).

(of course you need to do ssh-add ~/.ssh/<MY-PRIVATE-KEY> first though).

A bit of a Shame since this will NOT use the config file Contents.

Another Option might be to setup a Cron/Systemd Service or smth like that and periodically create a pre-merged File in ~/.ssh/config.merged for Instance.

But these are all Workarounds. Any Hope in getting a proper Fix ?

luckylinux commented 4 months ago

@jeanp413: Any hope of getting this Fixed ?

I think your Extension is using a custom "Interpreter" compared to the "Native" OpenSSH Client, as it's not really following all Files and Includes defined in ~/.ssh/config File.

The "Workaround" to set "The absolute file path to a custom SSH config file:" to $HOME/.ssh/config.d/* seems to suggest that at least.

Please correct if this Assumption is wrong of course.

zhengliw commented 4 months ago

As #32 suggested, I fixed the issue by putting the public key in the same directory as the private key, with the ending .pub... i.e. key key.pub Need to be in the same directory. Does this do it for you? Hmm...

luckylinux commented 4 months ago

@zhengliw: they Keys ARE in the SAME directory in my case.

$HOME/.ssh/config, $HOME/.ssh/myhostname.mydomain.tld [Private Key] and $HOME/.ssh/myhostname.mydomain.tld.pub [Public Key] are ALL in the SAME Directory to begin with. They were always like that ...

So, nope, #32 doesn't Help me at all unfortunately :(. Only my "Workaround" did the Job, but I'd like some better Solution to be implemented upstream.

zhengliw commented 4 months ago

Please excuse my ignorance...

luckylinux commented 4 months ago

No worries ...