Git keeps asking for password

0 votes
asked Jul 2, 2010 by user64718

I've searched and searched, for what seems like hours, for a solution to this problem and nothing I've tried works. Let me preface all this by saying that while I've used *nix before, I'm pretty much a noob so I'm sure I missed a step in the setup of Git somewhere.

I set up a Ubuntu box on the network at work to host our new Git repo. The box is running Git, Gitosis, and also ViewGit. Everything seems to be set up correctly, and I can view the repo I've added inside of ViewGit. The problem is when I go to clone the repo via TortoiseGit in Windows. When I type in the address of "git@10.10.0.144:/home/git/Plugins/.git/" it automatically asks for the password for the "git" user on the linux box. I can change this address from "git@" to any other username on the system and it will also ask for the password for that user. In any case, entering the password for that user continues the clone of the repo to the local system. Also branching, puts, and pulls will also ask for a password, and if entered everything functions properly.

I've created the RSA pub file on the windows boxes I've tried this on (via the git bash) and stored them in the keydir folder of gitosis, as well as adding the users gitosis.conf file (the name of the rsa file minus the .pub). I've also modified my sshd_config file to include "AllowUsers git" and also my username on the system. I'm at a loss, doesn't seem like a good idea to give everyone who I want to have access to this repository the server IP address, a username, and then the password to that username just so they can download some code. Thanks for the help!

3 Answers

0 votes
answered Jul 2, 2010 by bwawok

Went through this same exact thing on my box about 2 weeks ago :) You are 90% of the way there already.

To fix TortoiseGit, uninstall and reinstall it, but this time choose to use Putty P-Link instead of OpenSSH. Then when you go to push or pull to the project, check the little "autoload putty key" thing.

0 votes
answered Jul 31, 2011 by denis-fuenzalida

I had the same problem recently: I could clone/push to my gitosis-managed repo from Cygwin, but TortoiseGit kept asking for the password of the git user (git@192.168.1.30).

Finally I could make it work by reinstalling TortoiseGit (I selected the Plink option at install time), then on the TortoiseGit settings go to Network > SSH Client and change the value to your Cygwin ssh binary (ie. C:\cygwin\bin\ssh.exe).

By changing this I was able to do all the operations from TortoiseGit, and I'm asked for the password the SSH key which I defined on Cygwin.

Also, check that your gitosis.conf contains the public keys which are visible to Cygwin, removing the ".pub" extension: if my Cygwin install shows that I'm myuser@myhost, the associated entry on gitosis.conf should be myuser@myhost and the file with the public key should be on keydir/myuser@myhost.pub

0 votes
answered Sep 15, 2017 by jwg

First of all, the URL you use for cloning a git repo could be git+ssh as in your example, http/https, or various other things. Both SSH and HTTP are very common, and people often use SSH for authenticated users who will be able to push to the repo, and HTTP for other users, who can clone and pull, but can't typically push, or have limits on where they can push to. If you can view your repo in ViewGit, you can probably get an HTTP url for your repo, which you could use without logging in to clone or pull.

Now, if you want to continue with SSH, there are two things you need to look at:

You need to be able to connect to the server using SSH, without entering a password. If you're using cygwin SSH, you should be able to do

ssh git@10.10.0.144

and connect to that machine without being asked for a password. If you're using PuTTY, you should be able to open PuTTY, put in the hostname, and be asked for a username, but then connect without a password (or use the corresponding putty command line). Note that when you do this successfully, one of two things might happen. Either you get a normal shell on that machine as the git user. Or, you will see a short message, something like "SSH is set up correctly for using git." and the connection will close immediately.

If you can't do this, then you need to set up your public key on the git server, and load your private key into memory in your Windows box. The former is probably done through gitosis. For the latter you are going to use Pageant (if using Putty) or ssh-add if using cygwin ssh. If you need to, you can use a key without a passphrase at first. This will remove the step where you have to manually load the key and input the passphrase. Until you can connect like this via SSH without password, don't go onto the next step.

The second thing you need to do is configure what ssh your git client uses and how. If you can connect as above, but your git client can't connect, or can't connect without clone, then you need to set this up.

The basic idea is that you tell TortoiseGit exactly what the command-line to ssh to the git server is. You might need to check things like PATH and environment variables to make sure that TortoiseGit can replicate exactly how you connect using ssh. This answer https://stackoverflow.com/a/11249914/1737957 gives the basic idea.

Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter

...