support agent-less ssh operation

Labels: area/ssh kind/feature lifecycle/stale priority/important-longterm

Timeline

Norbert Melzer (NobbZ) opened

Please guide me to a way to provide additional information…

Yes, I use SSH URLs for git. No, they are not password protected.

If though starting SSH-Agent and adding the key, the error becomes:

Error: ssh: handshake failed: knownhosts: key mismatch

Regular git operations against the remote work.

patricioantoniotoledo (patricioantoniotoledo) commented

cd ~/.ssh ssh-add ~/.ssh/id_rsa

might help

Norbert Melzer (NobbZ) commented

To be honest, I do not even (want to) use SSH-agent.

I want the configured SSH-config to be respected and the command to just work.

I stoped using git-bug because of this a couple of days after posting this issue without a reply.

octvs (octvs) commented (edited)

Might be related, I had a similar issues prompting an handshake fail, which was fixed by building from source.

dllud (dllud) commented

I was facing the exact same error in the title. Besides starting a SSH Agent eval "$(ssh-agent -s)" and adding the key ssh-add ~/.ssh/mykey, I had to use a full URL (ssh://user@server.org:22/path/to/project.git) in the git remote. Only this got git bug push/pull working. This workaround was reported by @Subfortytwo at #572. It seems like the SSH Agent does not read my ~/.ssh/config?

Anyway, I am on the same page as @NobbZ: I would rather avoid using a SSH Agent. Is that possible? It wasn't needed last time I used git-bug (a couple years ago).

github-actions (github-actions) commented

This bot triages untriaged issues and PRs according to the following rules:

  • After 90 days of inactivity, the lifecycle/stale label is applied
  • After 30 days of inactivity since lifecycle/stale was applied, the issue is closed

To remove the stale status, you can:

  • Remove the lifecycle/stale label
  • Comment on this issue

github-actions (github-actions) added label lifecycle/stale

stackengineer (stackengineer) commented

Not stale. Also looking for an agentless solution, preferably respecting ~/.ssh/config.

github-actions (github-actions) removed label lifecycle/idle

sudoforge added label kind/feature

sudoforge added label priority/important-longterm

sudoforge added label area/ssh

sudoforge changed the title from support agent-less ssh operation to support agent-less ssh operation

sudoforge commented

catching up with some (old) comments here. i'm sorry there hasn't been a response on this issue.


@NobbZ:

If though starting SSH-Agent and adding the key, the error becomes:

Error: ssh: handshake failed: knownhosts: key mismatch

Regular git operations against the remote work.

hmm, this shouldn't be happening. if you can ssh to the host (or git push to it), git-bug should work as well (with a few caveats).

i've introduced a few fixes for ssh-related operations (namely: resolving the URI), but git-bug still doesn't read your ~/.ssh/config (which we need to do manually because go-git doesn't), so if you have custom ports or configuration in there, git-bug won't be able to pick it up.

if you (or someone else) is still able to reproduce this (with git-bug@v0.9.0 or greater), please let me know.


@dllud:

I had to use a full URL (ssh://user@server.org:22/path/to/project.git) in the git remote It seems like the SSH Agent does not read my ~/.ssh/config?

this shouldn't be the case anymore. i technically have fully qualified SSH URIs like this because i use url.*.insteadOf remapping, but i've tested without those using git's shorthand <user>@<hosname>:foo/bar.git and that works without issue. as mentioned above, however, custom configuration in ~/.ssh/config isn't parsed.


yes, i think that git-bug should "just work" like git does. getting to this point is a focus for me in the near term.

dllud (dllud) commented

Thanks for reviving this @sudoforge !

git's shorthand (scp like syntax) won't work for me (until ~/.ssh/config gets parsed) as I need to set a custom port. The scp like syntax does not allow setting a custom port number.

Current status for me on version 0.9.0 is:

  • A SSH Agent is still needed. If I try a git bug pull or push without starting an agent, I get:

Error: error creating SSH agent: "SSH agent requested but SSH_AUTH_SOCK not-specified"

  • ~/.ssh/config is not honored.

Hope you can find the time to fix both and get git-bug to seamlessly work just like git. ;)

sudoforge commented (edited)

git's shorthand (scp like syntax) won't work for me (until ~/.ssh/config gets parsed) as I need to set a custom port. The scp like syntax does not allow setting a custom port number.

yeah, this is something i know about -- parsing custom ssh config is on my radar.

in the meantime, if your only need is to specify a custom port, using the full RFC-3986-compliant URI would work for you:

ssh://you@host:1234/foo/bar.git

NOTE you could even handle this remapping in your git config using url.<base>.insteadOf configuration property.

support for this was added in git-bug:v0.8.1 (a150cdb0740d572cd5da9e8fd858168bf5796233)


A SSH Agent is still needed. If I try a git bug pull or push without starting an agent, I get:

Error: error creating SSH agent: "SSH agent requested but SSH_AUTH_SOCK not-specified"

yep - this is on my radar as well.

generally speaking, the way git-bug is currently written makes a lot of assumptions about your git configuration, your ssh configuration, and the types of remotes you're interacting with. these are the core issues i want to solve in the near term, as they are silly, and outright blocking people.