git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Git ksshaskpass to play nice with https and kwallet

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Oct 4, 2011, 10:19 UTC
Message-ID
<4E8ADDCF.6090406@drmicha.warpmail.net>

Checking out bitbucket and https, I came across a stupid issue between the default KDE setup (SSH_ASKPASS=/usr/bin/ksshakspass and KDE wallet) and the way we call the askpass helper, which makes the combo not work out of the box.

For those interested in getting it to work (or learning why it does not work out of the box), you can read the details formatted on my sparse blog (brain dump)

http://grubix.blogspot.com/2011/10/git-ksshaskpass-to-play-nice-with-https.html
or below if you don't feel like clicking through.

Cheers Michael

By default (with GIT_ASKPASS not set etc.), Git invokes $SSH_ASKPASS when it needs to ask you for credential info. In a KDE environment, SSH_ASKPASS is set to /usr/bin/ksshaskpass. So far so good.

But Git calls the askpass helper with a command line like /usr/bin/ksshaskpass Username for 'bitbucket.org': and once again with /usr/bin/ksshaskpass Password for 'bitbucket.org': So far so good.

But when asked to store the credentials in the KDE wallet, ksshaskpass tries (too) hard to guess a good key from that line. And for both invocations, it comes up with the same key (the URL), so that when the password info is needed, the username info from the wallet is returned. Authentication fails. Far from good.

If you still want to use the KDE helpers, you can save the little snippet #!/bin/bash set $* exec ksshaskpass $1\@$3 into ~/bin/git-ksshaskpass (and make it executable) and set

git config --global core.askpass ~/bin/git-ksshaskpass Gitcha!

NB:
    tested and works with https
    not tested with other methods (use ssh-agent)
    new credential helper interface coming in Git after 1.7.7
Next: Jeff King
Message 1 of 30 in “Git ksshaskpass to play nice with https and kwallet”
  1. Michael J GruberOct 4, 2011
  2. Jeff KingOct 4, 2011
  3. Michael J GruberOct 4, 2011
  4. Jeff KingOct 4, 2011
  5. Michael J GruberOct 4, 2011
  6. Jeff KingOct 4, 2011
  7. Michael J GruberOct 4, 2011
  8. Jeff KingOct 5, 2011
  9. Jeff KingOct 5, 2011
  10. Michael J GruberOct 6, 2011
  11. remote-curl: Obey passed URLMichael J Gruber, Oct 6, 2011
  12. Jeff KingOct 6, 2011
  13. Jeff KingOct 6, 2011
  14. Michael J GruberOct 12, 2011
  15. http_init: accept separate URL parameterJeff King, Oct 12, 2011
  16. Jeff KingOct 12, 2011
  17. Junio C HamanoOct 12, 2011
  18. Jeff KingOct 12, 2011
  19. Michael J GruberOct 13, 2011
  20. 0/6 http-auth-earlyMichael J Gruber, Oct 14, 2011
  21. Jeff KingOct 14, 2011
  22. Michael J GruberOct 14, 2011
  23. Junio C HamanoOct 14, 2011
  24. 1/6 url: decode buffers that are not NUL-terminatedMichael J Gruber, Oct 14, 2011
  25. 2/6 improve httpd auth testsMichael J Gruber, Oct 14, 2011
  26. 3/6 remote-curl: don't retry auth failures with dumb protocolMichael J Gruber, Oct 14, 2011
  27. 4/6 http: retry authentication failures for all http requestsMichael J Gruber, Oct 14, 2011
  28. 5/6 http: use hostname in credential descriptionMichael J Gruber, Oct 14, 2011
  29. 6/6 http_init: accept separate URL parameterMichael J Gruber, Oct 14, 2011
  30. Tay Ray ChuanOct 13, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.