Add SSH certificate, ProxyJump and manual host support - #42
Open
jappa wants to merge 1 commit into
Open
Conversation
Remote connections previously only worked for simple ~/.ssh/config entries. This adds: - OpenSSH certificate auth. ssh2 has no support for this, so getKeyAlgos() in ssh2/lib/client.js is patched at install time via patch-package (patches/ssh2+1.17.0.patch) and parseKey/authPK are monkey-patched in memory. CertificateFile is read from ssh config. - ~/.ssh/config parsing: follow Include directives (with globs and cycle detection), match multi-host lines, wildcards and negation, and apply first-value-wins precedence like OpenSSH does. Return null on no match rather than a bogus 127.0.0.1 config. - ProxyJump, including chained jump hosts and %r/%n/%h/%p tokens. Jump clients are torn down on error and close. - Disable the SSH agent when an unencrypted key is configured or IdentitiesOnly is set, to avoid exhausting auth attempts. - Manual host entry in the UI, persisted to customSshHosts in settings and merged into the saved hosts dropdown. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Remote SSH connections previously only worked for simple
~/.ssh/configentries: exactHostname match, no includes, no wildcards, no jump hosts, and a fallback to127.0.0.1:22whenever nothing matched. This PR makes remote connection handling work against realistic SSH setups.Certificate authentication
ssh2has no support for OpenSSH certificates. Two pieces are needed:getKeyAlgos()inssh2/lib/client.jsmust know how to pick a signature algorithm forssh-rsa-cert-v01@openssh.comkeys. That function is module-local and not exported, so it can't be monkey-patched at runtime — it's patched at install time bypatches/ssh2+1.17.0.patchvia apatch-packagepostinstallhook.keyParser.parseKeyandProtocol.prototype.authPKare patched in memory insrc/main.ts, so the parsed key presents the certificate blob as its public key and theUSERAUTH_REQUESTpacket carries the cert algorithm in the pubkey field but the base algorithm inside the signature block, as OpenSSH servers require.CertificateFileis now read from~/.ssh/configand plumbed through to the connection.SSH config parsing
Includedirectives recursively, with glob expansion and cycle detection.Host a b c), wildcards, and negation (!foo).nullwhen no host matches, instead of a default127.0.0.1:22config that would connect to the wrong machine.ProxyJump
establishSSHStream()resolvesProxyJump, handles chained jump hosts, expands%r/%n/%h/%p, and passes the forwarded stream assock. Jump clients are tracked and cleaned up on botherrorandclose.Agent vs. explicit key
If an explicitly configured key is unencrypted, or
IdentitiesOnly yesis set, the SSH agent is disabled. This fixes "too many authentication failures" where the agent burned all available attempts before the configured key was tried.Manual host entry
New Saved Hosts / Manual Entry toggle with host, port, username and key-path fields. Successful manual connections are saved to
customSshHostsin settings and merged into the dropdown. A manually typed name is still resolved against~/.ssh/config, so aliases work. The dropdown gains a-- Select SSH Host --placeholder rather than auto-selecting the first entry.Verification
node_modules/ssh2/lib/client.jsto pristine upstream 1.17.0 and rannpx patch-package; the result is byte-identical to the working patched file.npm ci, which triggerspostinstall, so the packaged asar ships already-patched.patch-packagedefaults to--error-on-failunderCI, so a futuressh2bump that invalidates the patch fails the build loudly rather than silently disabling certificate auth.npm run electron:buildtype-checks and compiles clean.patch-package's own dependency tree plus npm hoisting previously-nested copies; the only version move is dev-only transitivesemver7.8.1 → 7.8.5.Review notes
Not yet verified end-to-end in this branch. There is no automated coverage, and the certificate, ProxyJump and agent-disabling paths have not been run against a live server as part of preparing this PR. They need manual testing against a real cert-based host and a real jump host before merge. The
authPKpacket layout in particular is worth a close read.🤖 Generated with Claude Code