Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Alright, this is weird. First off, this is mintty running on up-to-date cygwin, with git pulled from cygwin's setup.exe. I am running zsh.

$ git clone https://<user>@<domain>/<repository>/ ~/src/project/dev
Initialized empty Git repository in /cygdrive/c/src/project/dev/.git/
Password: <actual password in plain text appears>
# Nothing happens...
^C
$ <password text that I just typed>
zsh: command not found: <same password text>

What is going on here? Is this a terminal problem, a shell problem, a git problem, or a cygwin problem?

Update: Yes, I'm running the Cygwin git version, not the Windows version:

$ which git
/usr/bin/git
$ git --version
git version 1.7.1
$ /cygdrive/c/Program\ Files\ \(x86\)/Git/bin/git.exe --version
git version 1.7.0.2.msysgit.0
share|improve this question
1  
I'm guessing a terminal problem. The fact that your password appears suggests that the terminal isn't properly being put into silent mode (where it doesn't show the characters you type), and the fact that the password text appears again after you hit ^C suggests that the characters aren't getting sent to stdin of the git process. But I don't know what the specific problem might be. –  David Z Jun 30 '10 at 17:09
    
Thanks for the clue - I came across this: code.google.com/p/mintty/issues/detail?id=56 - but there's no way to put git in interactive mode like the python executable... –  emptyset Jun 30 '10 at 18:09
1  
Are you sure you're invoking Cygwin's version of git? Mintty issue 56 only applies to native Windows programs. –  ak2 Jul 1 '10 at 5:15
    
Did you find a solution to this problem? –  pauldoo Dec 7 '10 at 12:38
add comment

8 Answers

up vote 5 down vote accepted

OK, I think I've found a definite solution.

The problem is that, regardless of the terminal used (puttycyg, mintty, cmd.exe), Git by default, in the absence of better configured alternatives, tries to use a "simple password prompt" (as you can read in the description of core.askpass config option).

The simple password prompt apparently only works on real UNIX, but not on Cygwin.

The solution is to install an SSH_ASKPASS compatible program for Windows and configure Git to use it.

What I did was:

  1. Install win-ssh-askpass application by unpacking and copying to C:\
  2. Download and install the Borland Delphi 5 runtime required by win-ssh-askpass (hard to come by nowadays, but found one on http://www.satsignal.eu/software/runtime.html)
  3. Configure Git to obtain passwords using win-ssh-askpass: git config --global core.askpass "C:/win_ssh_askpass.exe". Note that the EXE file has underscores in its name, not minus signs.
  4. Remember to always place your login in the URL (https://<user>@<domain>/<repository>). Otherwise, Git will ask for the login before asking for the password, using the same askpass utility. You may unknowingly input your password as the login, which will be sent to the webserwer and logged in its access log as plain text!

Now Git asks for the password using an elegant GUI window and works regardless of the terminal used :)

share|improve this answer
    
thanks, run randomly, but runs :) I don't know why git don't run as expected. subversion do it fine. –  corretge Feb 20 '12 at 16:59
add comment

I've experienced the same issue - however in my case I am SSH'd in the Cygwin server so obviously a Win32 GUI askpass won't work.

Instead, I wrote this simple script to do the askpass. I though it could be used from regular prompts as well by getting the tty device from /bin/tty.exe but that didn't work for an unknown reason (feel free to tty yourself or look for another solution to get the tty, maybe I just got it wrong somehow).

/bin/askpass.sh:

#!/bin/bash

TTY=$SSH_TTY
[ -c "$TTY" -a -r "$TTY" -a -w "$TTY" ] \
  || { echo "Failed to open device \`$TTY'!"; exit 1; }
exec <$TTY

echo -n "$@" >$TTY
read -s P
echo >$TTY

echo $P

Make sure this script is executable and use it as your git's core.askpass setting. Since this script relies on the $SSH_TTY variable it will normally only work from SSH. You could however set $SSH_TTY in .bashrc or .bash_profile if unset; this way it should work even from a console. The following line in your rc script should do it:

[ -z "$SSH_TTY" ] && export SSH_TTY=$(/bin/tty.exe)
share|improve this answer
    
I can confirm this solution, works very well. –  schlamar Mar 7 '12 at 13:04
    
This worked pretty well for me too. However, I had to add a redirect (1>&2) on that "Failed to open ..." message in order for it to be visible. –  Eric Apr 3 '12 at 18:34
add comment

It's possible you have a metacharacter, such as &, in the URL. This would cause git to run in the background, and on a Unix system it would be stopped as soon as it tried to read from stdin. A ; would also terminate the command partway through the line, and the Ctrl-C would cause the rest of the line (a separate command) to be aborted.

It's interesting that git initializes the repo in /cygdrive/c/src/project/dev/.git/ even though you told it to use ~/src/project/dev (unless you have your home directory in a strange place). This would suggest that the git command is not seeing the rest of the command line, which is what would happen if there was a stray & or ; in the URL.

(I've had this problem lots of times with wget, although not with git.)

Try a git clone from a different repo, or using a different transport from the same repo, to see if git is messed up generally or just for this repo. You could also try putting single quotes around the URL.

share|improve this answer
    
~/src is a symlink to /cygdrive/c/src (C:\src). There's no & in the URL. I'll try to clone a public git repository, but generally those won't have a password... –  emptyset Jul 6 '10 at 13:58
add comment

Take a look at the following issue - I'm fairly certain now it's just a limitation of mintty and interoperability with Windows.

Issue 56 - mintty

I've also had problems running mysql and such from mintty - so, the answer is that it's a terminal emulation problem.

share|improve this answer
add comment

Years ago I remember having some problems with Cygwin's CVS authentication... it was to do with whether you installed Cygwin with the DOS or Unix style line endings (CRLF vs just LF); it's one of the options on the installer dialog. If you picked the wrong one (I think DOS was the one which worked) the password would end up mangled or with a spurious character or something.

Anyway, might be worth trying the other option.

share|improve this answer
add comment

I have the same problem, and, contrary to this thread, the problem occurs with Cygwin GIT in all possible terminals - puttycyg, mintty and the classical Windows cmd.exe.

I'm still looking for a proper solution, but there's a workaround - although it's very insecure, you can try placing the password in repository URL, e.g.:

git clone https://<user>:<password>@<domain>/<repository>/

Does the workaround work for you?

share|improve this answer
add comment

If it's a repository you use often, the easiest thing may be to create a ~/.netrc file with

machine git.example.com
login yourlogin
password your password

Obviously, you should set appropriately draconian permissions on the file.

share|improve this answer
add comment

Just a refinement on comment #2

There's a cygwin ssh-ask-pass (unofficial) here

Just download the tar.bz2 and unpack into your cygwin folder. It works without installing borland delphi runtime.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.