Git keeps asking for password

前端 未结 3 562
半阙折子戏
半阙折子戏 2021-01-18 17:00

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 use

相关标签:
3条回答
  • 2021-01-18 17:46

    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 讨论(0)
  • 2021-01-18 17:49

    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.

    0 讨论(0)
  • 2021-01-18 17:58

    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 讨论(0)
提交回复
热议问题