Git keeps asking for password

前端 未结 3 602
半阙折子戏
半阙折子戏 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: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.

提交回复
热议问题