Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent git from popping up gnome password box

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.

like image 733
Los Frijoles Avatar asked Jan 29 '14 05:01

Los Frijoles


People also ask

How do I get git to stop asking for password?

You can avoid being prompted for your password by configuring Git to cache your credentials for you. Once you've configured credential caching, Git automatically uses your cached personal access token when you pull or push a repository using HTTPS.

How do I change my git password in Linux?

Using git config to store username and password: | git config --global --add user. password | |---- 1.1 first time entry | git config --global --add user. password <new_pass> | |---- 1.2 password update | git config --global --unset user. password | git config --global --add user.


Video Answer


2 Answers

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

like image 187
Nick McCurdy Avatar answered Oct 24 '22 03:10

Nick McCurdy


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
like image 1
user2679859 Avatar answered Oct 24 '22 04:10

user2679859