29

I have not asked a question of this nature before, so this may not be the correct site for this.

I use the xfce terminal in drop-down mode connected to a hotkey. It closes when another window becomes active, which is just fine. What is not fine, however, is that when I use git and have it pull or push to an https url, it pops up a fun box to ask me for my password instead of just letting me enter it directly on the command line.

Normally I would google around to find the answer to this, but sadly most people are trying to get git to stop asking for a password altogether rather than prevent a dialog box, so this is hard for me to google (trust me; I've tried for a couple months now on and off when I get annoyed enough).

How can I prevent git from popping up any graphical windows for things like passwords? Git says that it is using /usr/lib/seahorse/seahorse-ssh-askpass for asking the password, so if there is some configuration option to prevent it from using that (or that has an equivalent effect), that would be great.

Thanks very much for any help.

Los Frijoles
  • 4,771
  • 5
  • 30
  • 49

2 Answers2

31

It seems like git is probably using the GIT_ASKPASS or SSH_ASKPASS environment variables to figure out if it should use a separate program to prompt for passwords.

Try running unset GIT_ASKPASS or unset SSH_ASKPASS. Now try pushing or pulling from a git repository. If that works, add the appropriate command to .bashrc, .zshrc, or whatever file you use to run a command when your shell starts.

You can also override the value of git's core.askpass setting with git config --global core.askpass YOUR_PREFERRED_PROMPT_COMMAND.

Relevant information from the git-config man page:

core.askpass

Some commands (e.g. svn and http interfaces) that interactively ask for a password can be told to use an external program given via the value of this variable. Can be overridden by the GIT_ASKPASS environment variable. If not set, fall back to the value of the SSH_ASKPASS environment variable or, failing that, a simple password prompt. The external program shall be given a suitable prompt as command line argument and write the password on its STDOUT.

Original source: http://kartzontech.blogspot.com/2011/04/how-to-disable-gnome-ssh-askpass.html

kirypto
  • 129
  • 2
  • 14
Nick McCurdy
  • 17,658
  • 5
  • 50
  • 82
  • Is there a way to tell git to ignore SSH_ASKPASS if it's set? I mean, what program gets called if SSH_ASKPASS is unset? – naught101 Nov 26 '15 at 05:29
  • It checks for `GIT_ASKPASS`, then `core.askPass`, then `SSH_ASKPASS`, and then it prompts you on the terminal. It's possible that your graphical environment might set one of these variables to one of its default credential helpers. Check out this man page for more information: https://www.kernel.org/pub/software/scm/git/docs/gitcredentials.html – Nick McCurdy Nov 26 '15 at 05:32
  • I know, what I mean is, what is called if none of those variables are set? Because you could just add that to `core.askpass`, and ignore the `SSH_ASKPASS` all together. – naught101 Nov 26 '15 at 05:36
  • 8
    If you are on Windows and simply want to disable the GUI for this, run `git config --global core.askpass ""` – brettwhiteman Nov 27 '15 at 01:14
1

unset DISPLAY when running git commands that might need password, and gnome-ssh-askpass will use a text terminal prompt.

For example:

DISPLAY= git push
user2679859
  • 121
  • 2