gitui icon indicating copy to clipboard operation
gitui copied to clipboard

How to push using ssh key?

Open Wyfy0107 opened this issue 3 years ago • 13 comments

Describe the bug I use mostly ssh key to push and when using gitui to push it jusr error out with git error:Couldn't find credentials

To Reproduce Steps to reproduce the behavior:

  1. Install gitui with homebrew
  2. Open gitui
  3. Type p to push
  4. See error

Expected behavior It should just use the configured ssh key from ssh-agent

Screenshots If applicable, add screenshots to help explain your problem.

Context (please complete the following information):

  • macOS Montery 12.1
  • GitUI Version 0.21.0

Additional context Add any other context about the problem here.

Wyfy0107 avatar Sep 21 '22 19:09 Wyfy0107

I have the same problem, wondering if there is something to configure for that? I didn't find any option to link my existing SSH key...

ClementNerma avatar Oct 03 '22 16:10 ClementNerma

I can confirm on

  • macOS Ventura 13.0.1 (M1)
  • gitui 0.21.0

Is this possibly connected to the "Bad Credentials" problem mentioned in the FAQ? I'm using vanilla ssh public key authentication w/o ssh-agent.

An earlier bug report was asking for an offending URL. I can't share mine either (private machine), but the schema follows the below pattern:

ssh://my.machine.de:/~/git/projects/project.git

dl1ngo avatar Nov 12 '22 08:11 dl1ngo

Another one, i think there should be an option to define ssh keys path

Talleyrand-34 avatar Jan 03 '23 16:01 Talleyrand-34

problem is actual

melonges avatar Jan 18 '23 18:01 melonges

I'm using a custom SSH key for the failing repo, meaning that in ~/.ssh/config a specific key path is defined for that host via IdentityFile. Gitui doesn't respect that (I guess you just ship ssh and use the git config). So this fails with git error:Bad credentials.. Doesn't look like you can tell git itself to use a specific key. At least git config core.sshCommand 'ssh -i private_key_file -o IdentitiesOnly=yes' doesn't seem to work. git push origin by itself works.

0xpr03 avatar May 03 '23 20:05 0xpr03

same problem too @extrawurst

olivertzeng avatar Jun 26 '23 03:06 olivertzeng

I'm using a custom SSH key for the failing repo, meaning that in ~/.ssh/config a specific key path is defined for that host via IdentityFile. Gitui doesn't respect that (I guess you just ship ssh and use the git config). So this fails with git error:Bad credentials.. Doesn't look like you can tell git itself to use a specific key. At least git config core.sshCommand 'ssh -i private_key_file -o IdentitiesOnly=yes' doesn't seem to work. git push origin by itself works.

I got this response on Discord a while back:

The underlying issue is that libssh2 itself doesn't care about ~/.ssh/config. It has been a source of complaint for many users who were bitten by this, and I myself find it unfortunate, too. But we certainly do not want to implement support for parsing the SSH configuration ourselves, and I think implementing just a subset of it that is not even applied via ~/.ssh/config is not really worth it.

Not sure what state this is in today, but it seems that it's still the issue.

predmijat avatar Aug 18 '23 16:08 predmijat

Stuck with the same problem. The only option I found is to use ssh-agent as a key provider. This, unfortunately, requires changing the workflow when working with multiple identities. Removing all the keys with ssh-add -D and then adding only a project-specific key to agent with ssh-add ./ssh/current_project_key solves the problem for me.

P.S. If anybody knows the way to automate key selection for ssh-agent depending on current environment, please let me know. But it seems to me this requires creating bash/zsh/nvim plugin

silentz avatar Aug 23 '23 12:08 silentz

https://github.com/libgit2/libgit2/pull/6617 - soon supported by upstream

extrawurst avatar Aug 31 '23 08:08 extrawurst

The upstream has added OpenSSH support, any updates here?

Bryan2333 avatar Dec 20 '23 09:12 Bryan2333

Same problem here. Any fix in sigth?

itdhsc avatar Feb 16 '24 12:02 itdhsc

same problem. any news?

t-bruns avatar Jun 27 '24 10:06 t-bruns

Once there are any updates they happen here first :)

extrawurst avatar Jun 27 '24 10:06 extrawurst