Discussion:
[pass] Using pass with git config core.askpass
Alexander Baier
2014-11-18 21:41:00 UTC
Permalink
Hello,

I would like to use pass to supply git with login information when
accessing a remote repository (e.g. on github). I put the following
section into my ~/.gitconfig:

[core]
askpass = pass show Code/github.com

Doing 'git push' will now print

"error: cannot run 'pass show Code/github.com': No such file or
directory"

and will continue with prompting me for my username and password:

Username for 'https://github.com':
Password for 'https://***@github.com'

Does anyone know how I can tell git to use pass for retrieving my
credentials?

Regards,
--
Alexander Baier
James Cameron
2014-11-18 21:55:22 UTC
Permalink
Post by Alexander Baier
I would like to use pass to supply git with login information when
accessing a remote repository (e.g. on github). I put the following
[core]
askpass = pass show Code/github.com
Doing 'git push' will now print
"error: cannot run 'pass show Code/github.com': No such file or
directory"
My guess is that askpass requires a single path, so make a script that
contains what you need:

% cat >>github-askpass <<EOF
#!/bin/sh
exec pass show Code/github.com
EOF
% chmod +x github-askpass

And then in .gitconfig

[core]
askpass = /path/to/github-askpass
--
James Cameron
http://quozl.linux.org.au/
Alexander Baier
2014-11-21 07:30:46 UTC
Permalink
[ This answer does not seem to have arrived on this list, so I am
sending it again.]
Post by James Cameron
Post by Alexander Baier
I would like to use pass to supply git with login information when
accessing a remote repository (e.g. on github). I put the following
[core]
askpass = pass show Code/github.com
Doing 'git push' will now print
"error: cannot run 'pass show Code/github.com': No such file or
directory"
My guess is that askpass requires a single path, so make a script that
% cat >>github-askpass <<EOF
#!/bin/sh
exec pass show Code/github.com
EOF
% chmod +x github-askpass
And then in .gitconfig
[core]
askpass = /path/to/github-askpass
This put me on to right track, thank you! I finally came up with the
following:

#+BEGIN_SRC sh
#!/bin/sh
if [[ "Username" = ${1:0:8} ]]; then
exec pass show Code/github.com | sed -n s/user://gp
elif [[ "Password" = ${1:0:8} ]]; then
exec pass show Code/github.com | grep -v '^user:'
fi
#+END_SRC

Git invokes the program specified with core.askpass twice, once for the
username and once for the password. The specified program is passed the
current prompt as an argument.

Regards,
--
Alexander Baier
Alexander Baier
2014-11-19 11:25:46 UTC
Permalink
Post by James Cameron
Post by Alexander Baier
I would like to use pass to supply git with login information when
accessing a remote repository (e.g. on github). I put the following
[core]
askpass = pass show Code/github.com
Doing 'git push' will now print
"error: cannot run 'pass show Code/github.com': No such file or
directory"
My guess is that askpass requires a single path, so make a script that
% cat >>github-askpass <<EOF
#!/bin/sh
exec pass show Code/github.com
EOF
% chmod +x github-askpass
And then in .gitconfig
[core]
askpass = /path/to/github-askpass
This put me on to right track, thank you! I finally came up with the
following:

#+BEGIN_SRC sh
#!/bin/sh
if [[ "Username" = ${1:0:8} ]]; then
exec pass show Code/github.com | sed -n s/user://gp
elif [[ "Password" = ${1:0:8} ]]; then
exec pass show Code/github.com | grep -v '^user:'
fi
#+END_SRC

Git invokes the program specified with core.askpass twice, once for the
username and once for the password. The specified program is passed the
current prompt as an argument.

Regards,
--
Alexander Baier
Quentin Minster
2014-11-19 21:37:28 UTC
Permalink
Post by Alexander Baier
Hello,
I would like to use pass to supply git with login information when
accessing a remote repository (e.g. on github). I put the following
[core]
askpass = pass show Code/github.com
Doing 'git push' will now print
"error: cannot run 'pass show Code/github.com': No such file or
directory"
Does anyone know how I can tell git to use pass for retrieving my
credentials?
Regards,
--
Alexander Baier
Hello,

I use a git credential helper [1] for this (attached).

It must be located in your path for git to find and use it (and the name
'git-credential-pass' is actually important).

Then you can use the following configuration in your .git/config:

[credential]
helper = pass Code/github.com

Hope this helps.
Regards,
--
Quentin Minster

GPG Public Key : 0F5F912C
GPG Fingerprint : AA09 29D0 263B E9D6 C260 BDC5 FF79 BF27 0F5F 912C



[1]: http://git-scm.com/docs/gitcredentials
Alexander Baier
2014-11-21 07:40:11 UTC
Permalink
[ My initial post ]
Post by Alexander Baier
Hello,
I use a git credential helper [1] for this (attached).
It must be located in your path for git to find and use it (and the name
'git-credential-pass' is actually important).
[credential]
helper = pass Code/github.com
I already applied a solution (see the my other post in this thread), but
it is nice to see, how it would work with a git credential helper,
thanks!

Regards,
--
Alexander Baier
Loading...