Gitup: Improve error message when SSH key is locked

Created on 2 Mar 2016  路  23Comments  路  Source: git-up/GitUp

When an SSH key is password protected and not added to the ssh agent, the error gitup produces is:

Failed connecting to "origin" remote: authentication required but no callback set

Gitup should either produce a sane error message explaining that the SSH key cannot be unlocked or (better) prompt for the SSH key password (ideally add it to ssh agent).

enhancement

Most helpful comment

Turns out my issue was due to ssh-agent forgetting my key. This solved it:

ssh-add ~/.ssh/id_rsa

The actual issue title is still relevant I guess :)

All 23 comments

How can I work around this? Pushing from command line works with the ssh key added to ssh agent but I can't push using gitup.

I think the diagnosis of this error is incorrect. ssh agent and up and running and keychain is unlocked. Gitup still refuses to do a remote push.

Any hints on what's going @swisspol ?

No idea, sorry. It's not something I have observed myself so someone would need to build GitUp locally and trace in the code what is happening.

I'm not sure what configuration causes this, but on my machine with the problem SSH asks for the key password in terminal instead of using the normal keychain dialog. It also doesn't seem to store the passwords in any place keychain access can find them, despite ssh -vv showing it is getting the password from keychain. I didn't realise this had happened until I tried to use GitUp and hit this issue.

I wonder if it's related to iCloud keychain?

I can't compile GitUp on this machine because I'm running 10.12 beta, on my 10.11 test machine where I was able to compile it SSH asks for key passwords the normal way and GitUp is fine. I did notice however that if I haven't unlocked a key at the console on that machine I get the same "no callback set" error, with this in the log:

[ERROR ]> libgit2 error (-1): authentication required but no callback set

@TheSpyder why is GitUp not compiling on 10.12?

ld: library not found for -lcrypto

It might just be the Xcode beta, but the macOS 10.12 SDK is missing library files like libcrypto and libz that I can see are there in the 10.11 SDK. I found them in /usr/lib on my system but when I tried to make the build use those it still gives me the error.

See #210 for the 10.12 compiling issue.

yeah, I didn't mean to turn this into a 10.12 compiler issue.

I think the important point here is that I have one environment where GitUp can access my key successfully, and one where it fails with the 'no callback set' message - using the same key. The only significant difference I can see is that where it doesn't work SSH key passwords are requested directly in a terminal prompt instead of with an OS keychain password dialog.

I just experienced this for the first time after upgrading to macOS 10.12.

No idea what has changed, but it effectively makes GitUp local-only

Turns out my issue was due to ssh-agent forgetting my key. This solved it:

ssh-add ~/.ssh/id_rsa

The actual issue title is still relevant I guess :)

@jokkedk not worked for me.
I regenerated keys, added them, reconfigured config file in ssh folder.
console git works fine, but not a gitup.
However, it could be related to passphrases? and ssh-add -K <key>. I didn't do it.

ssh -v [email protected]
...

Hi lolgear! You've successfully authenticated, but GitHub does not provide shell access.

ssh -v [email protected]
...
Exit status 0.

@jokkedk Worth to note that macOS Sierra no longer saves SSH keys in OS's keychain, every time you restart your computer, you'll have to execute ssh-add.

https://openradar.appspot.com/27348363

it would be nice if we could come up with a solution to prevent this from happening.

That only impacts connections that use the agent, though, after reboot at the terminal I can make SSH connections that use my passworded key without doing ssh-add.

See comment from Apple about this bug:

That鈥檚 expected. We re-aligned our behavior with the mainstream OpenSSH in this area.

You can fix this pretty easily by running ssh-add -A in your rc script if you want your keys to always be loaded.

That's how I ended up solving the issue on my side, but that's after searching a lot and finding that link.

New or less experienced users might think it is a problem with GitUp. I've tried to reproduce the issue with other Git tools, e.g. SourceTree and I wasn't able, so clearly they are doing something to avoid this.

GitUp uses libgit2 and therefore must use libssh2 for talking to ssh remotes, it cannot use the ssh CLT like git CLI or these tools, which means it cannot behave the exact same unfortunately.

right, that makes sense I guess. Confirmed that running ssh-add -A in terminal makes GitUp work.

~Still running into this issue on a fresh install of Mojave (10.14.4). Able to push from command line, but not from GitUp.~ Nevermind. I was able to get it to work by simply running ssh-add -K

FWIW, I just had this problem, and the only reason I could sort things out was by googling for the error I got and finding this issue.

If you need a way to replicate, what happened for me was:

  • Power-cycle (rebooting might also work)
  • Have Terminal automatically re-launch, including loading windows open before I rebooted, which were connecting to various machines using ssh
  • Try to push to a remote origin; get this error
  • Find a terminal which was prompting me to enter my ssh-agent password
  • Ctrl-C, run ssh-agent, enter my passwod
  • Pushing to a remote origin now works

Sorry, run ssh-add, not ssh-agent.

I am on MacOS Catalina Version 10.15.7 and the GitUp version is 1.1.3, and the solution ssh-add ~/.ssh/id_rsa no longer works for me. I'm still getting Failed connecting to "origin" remote: authentication required but no callback set despite the solution and I've tried using the -K option as well. In my terminal the Git SSH works fine.

I implemented both techniques from this stack overflow answer - a LaunchAgent that runs ssh-add -A when I login, and AddKeysToAgent in my SSH config - and haven't had a problem since.
https://stackoverflow.com/a/40093231/7546

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zmc picture zmc  路  7Comments

lolgear picture lolgear  路  5Comments

adius picture adius  路  5Comments

andrewsawczyn picture andrewsawczyn  路  3Comments

codymikol picture codymikol  路  3Comments