94

I just started to work on Git. I use windows 7 and has installed msysgit(1.7.8) and Tortoisegit(1.7.6). The repository is created on Linux server which is accessible thru LAN. The issue I'm facing is I'm not able to clone the repository using Tortoisegit, it asks for password and I'm not sure what password it is asking. At the same time I could clone the repository using Git Gui and do all operations. Can anybody please help me on understanding why Tortoisegit is asking password when Git Gui doesn't. I tried uninstalling Git and Tortoisegit and then install again but no success.

Tortoisegit error

pramodtech
  • 6,300
  • 18
  • 72
  • 111
  • your git server is using a pubkey auth? – Felix Yan Jan 13 '12 at 07:15
  • On the SAME clone of the repo, what is TortoiseGit doing and what is Git GUI doing? – manojlds Jan 13 '12 at 09:15
  • 2
    When you right click for Tortoise Git, click Settings. At Git, there is a link -> Remote, click it. From remote list click origin. At right you will see URL. Instead of your username at URL wright that: username:. Finally when you make a git operation from Tortoise Git you will see that it never asks you about password. – kamaci Jan 05 '13 at 16:55
  • 1
    Are you using the http URI instead of SSH? That was my problem – CAD bloke Jan 31 '13 at 11:09
  • For the "special ones" amongst us (me included) remember to remove the 'git clone' bit from the front of the command before pasting it into the URL window of the Tortoise Git Clone window - otherwise you get similar issues – icc97 Jun 17 '13 at 12:21
  • check also http://stackoverflow.com/questions/14000173/tortoisegit-save-user-authentication-data – Murali Murugesan Nov 08 '13 at 21:27

17 Answers17

153

My colleague solved the problem. Steps:

  1. Right click -> TortoiseGit -> Settings -> Network
  2. SSH client was pointing to C:\Program Files\TortoiseGit\bin\TortoisePlink.exe
  3. Changed path to C:\Program Files (x86)\Git\bin\ssh.exe

Alternatively:

  • C:\Users\...\AppData\Local\Programs\Git\usr\bin\ssh.exe
  • C:\Program Files\Git\usr\bin\ssh.exe - with Git 2.37.3
Alen Siljak
  • 2,482
  • 2
  • 24
  • 29
pramodtech
  • 6,300
  • 18
  • 72
  • 111
  • it works for me with tortoise version 1.8.3... this problem maked me crazy!! on windowsXP@32 bit tortoisegit works only with c:\programmi\git\bin\ssh.exe on Windows7@64 it works well with toirtoiseplink.exe (default) – Evilripper May 31 '13 at 10:25
  • On my Windows 8 machine, pointing the SSH client to the msysGit ssh.exe file worked when the password query didn't show up at all. A different problem but this solution is definitely worth a try for someone experiencing ssh problems with TortoiseGit – Icermann Aug 19 '13 at 18:39
  • use plink with peagent, see my answer below. hopefully it works with win8 as well – mzzzzb Sep 03 '13 at 17:19
  • This solution worked for me when I was *not* being prompted for a password. – Peter Dec 03 '13 at 05:24
  • it didn't fix and I'm getting an error pasted below, any advice? --> ssh: connect to host github.com port 22: Bad file number fatal: Could not read from remote repository. – Mustafa Güven Jan 21 '14 at 13:17
  • ssh.exe seems to show passwd prompt using command-line passed by `SSH_ASKPASS` environment variable. TortoisePlink.exe doesn't? – kenjiuno Aug 10 '15 at 04:27
  • 1
    For me this did not help (at least when connecting to GitHub, I did not try other repositories). – Suma Sep 02 '15 at 08:22
  • 4
    Thanks, worked perfectly. Although my `ssh.exe` lies in my user directory `C:\Users\...\AppData\Local\Programs\Git\usr\bin` – ppasler Nov 23 '16 at 07:38
  • I needed to set it to ...\git\usr\bin\ssh.exe, so it's worked! – Jardel Novaes Dec 12 '16 at 16:20
  • 7
    As @ppasler mentioned, ssh.exe is now located in C:\Program Files (x86)\Git\usr\bin\ssh.exe or the location he mentioned, depending on the installation. – Vlad Schnakovszki Apr 25 '17 at 09:12
47

If you need to use a username/password, there is a much simpler solution than the current #2 answer:

Right-click --> Tortoise Git --> Settings --> Git --> Credential --> Choose "Wincred, all Windows users" --> Hit apply

The next time you enter the password for a repo, that password will be automatically saved.


If you're using a repository that requires SSH keys rather than username/password (which it sounds like was OP's original issue), you need to

  1. Open the SSH key in PuTTY gen (installs itself alongside Tortoise Git)
  2. In PuTTY gen, save the key as a PuTTY key.
  3. In the repository, Right-click --> Tortoise Git --> Settings --> Git --> Remotes. Find your remote (usually 'origin') then load the PuTTY key from step 2.
BlueRaja - Danny Pflughoeft
  • 84,206
  • 33
  • 197
  • 283
23

To do it without keys...

Right click on your folder
Select tortoiseGit->settings->Git->Remote
Select origin (or whatever you have labeled your main remote)

Under URL use this format.

Https://USERNAME:PASSWORD@URL

Where USERNAME is your username
: the colon separates username and password and must be there
PASSWORD is your password
@ separates credentials with your url
URL is the url you would use to connect to the .git resource

Thanks goes to Kamaci

Hugh Fuve
  • 346
  • 2
  • 4
  • 3
    This solution also work with key. Clone Https://USERNAME@URL and you are fine. – Orace Nov 28 '14 at 09:51
  • 2
    Yep, except don't do this because when you do a merge TortoiseGit is inclined to put the *whole* URL into the commit message! – mwardm Apr 30 '15 at 14:26
  • This is the perfect solution. But is there any way to hide the password, since its in plain text. – Amit Kumar Aug 29 '15 at 10:34
  • 2
    What if password contains @ sign? – Hammad Dar Jul 04 '16 at 16:27
  • I resorted to using this answer because I have mingw64 and I get this log: Skipping command-line '"C:\Program Files\Git\mingw64\bin\..\usr\bin\bash.exe"' ('C:\Program Files\Git\mingw64\bin\..\usr\bin\bash.exe' not found) Need a valid command-line; Edit the string resources accordingly (3x) error: failed to execute prompt script (exit code 1) – C4F Nov 07 '16 at 17:20
15

Saving username and password with TortoiseGit

Saving your login details in TortoiseGit is pretty easy. Saves having to type in your username and password every time you do a pull or push.

  1. Create a file called _netrc with the following contents:

    machine github.com
    login yourlogin
    password yourpassword

  2. Copy the file to C:\Users\ (or another location; this just happens to be where I’ve put it)

  3. Go to command prompt, type setx home C:\Users\

Note: if you’re using something earlier than Windows 7, the setx command may not work for you. Use set instead and add the home environment variable to Windows using via the Advanced Settings under My Computer.

CREDIT TO: http://www.munsplace.com/blog/2012/07/27/saving-username-and-password-with-tortoisegit/

Anthony Keane
  • 519
  • 7
  • 14
  • 1
    it works just nice, but is there a way to encrypt the plain password ? I felt uncomfortable storing my github password in plain text file. – Dio Phung Jun 04 '14 at 15:42
  • @DioPhung Think about what you just said. If the password is encrypted, you'd now need to remember a (new) password for using the password. If you don't have to remember the password, then it's as good as not having a password (from a local threat perspective). Either you want convenience or safety. – Camilo Martin Aug 10 '14 at 04:49
  • @CamiloMartin: My concern is if my PC is shared with some other users and some of them are administrators, then they can see my password which stored in plain text inside `_netrc` file. Sorry I lost you at ` If the password is encrypted, you'd now need to remember a (new) password for using the password.` , can't I hash the password using itself ? – Dio Phung Aug 11 '14 at 03:08
  • 1
    @DioPhung If you are afraid of local administrators, they can easily install a keylogger. A local administrator can do whatever he/she wants with your data, and as such, any security against them would be security through obscurity (even tools and tricks that banks use can't protect you against a knowledgeable and determined local administrator, and they do try hard). Regarding hash, what do you mean? A hash is non-reversible. And if you encrypt using the password itself, you'll *still* need to type it every time... So it's the same as not encrypting it in the first place. – Camilo Martin Aug 11 '14 at 08:09
  • @DioPhung On a hopefully more helpful note to your particular situation, you may want to look [*here*](http://stackoverflow.com/a/4356869/124119), and also ask about [BYOD](http://en.wikipedia.org/wiki/Bring_your_own_device) possibilities if you have a laptop. – Camilo Martin Aug 11 '14 at 08:11
  • 1
    @CamiloMartin encryption does not require a password; there are many ways to authenticate with a system that may be more convenient than a password. Security isn't all or none. – adam Jul 11 '15 at 14:37
  • @DioPhung "is there a way to encrypt the plain password" [yes](http://stackoverflow.com/a/31358149/2238178). – adam Jul 11 '15 at 14:39
  • 1
    While this solution is possible, it is a better idea to store the password in Windows [PasswordVault](https://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.security.credentials.aspx). This ability has been available in TortoiseGit since March 2013 by implementing the API [git-credential-store](http://gitcredentialstore.codeplex.com/). It's probably easier too: `From within repo → Context-click → TortoiseGit → Settings → Git → Credential → wincred → OK` and you are done. I wrote a [full answer](http://stackoverflow.com/a/31358149/2238178) to this question for those interested. – adam Jul 11 '15 at 15:02
8

I had the same issue. My environment is windows 10 with TortoiseGit 2.3.0.0 and git version 2.11.0.windows.1

The following solved my problem:

  • Right click -> TortoiseGit -> Settings -> Network
  • Update SSH client to C:\Program Files\Git\usr\bin\ssh.exe

enter image description here

Community
  • 1
  • 1
silver
  • 1,633
  • 1
  • 20
  • 32
5

One way to do this is

  • generate a keypair using PuttyGen, (or import into .ppk if you already have a key)
  • load the private key to peagent
  • import public key to you gitosis server (supply your public key to your admin)
  • and then use plink as SSH client

plink works natively with peagent to retrieve the loaded key.

you can find plink.exe along with peagent and other goodies in standard putty distribution

to use it go to:

TortoiseGit Settings -> Network -> SSH client .

by default this contains path to TortoisePlink.exe, instead of that give path to plink.exe

Alternatively you can use ssh(.exe) in msys(git) distribution but then you cannot use private key in .ppk format/Peagent combination. You either need to export your key to OpenSSH format via PuttyGen or create a keypair using ssh-keygen instead.

mzzzzb
  • 1,422
  • 19
  • 38
  • What do you mean by "SSH client instead of TortoisePlink point to plink"? Where is this SSH program likely located? – Mikaël Mayer Apr 14 '14 at 10:32
  • sorry for missing punctuation, I think that's the source of confusion. I ve updated the answer – mzzzzb Apr 14 '14 at 15:06
  • No need to change anything in the settings. Just provide the private Putty key when you clone a repo via SSH and you're done. Do remember to enter the SSH endpoint in the clone window and NOT the https one. – MoonStom May 22 '15 at 18:05
5

To automate authenticating either use:

  1. SSH keys as others have already pointed out, or
  2. the built-in credential helper.

Obviously, do not store your password in a text file unless the repo is not important.

TortoiseGit >1.8.1 installs the helper git-credential-winstore which provides the local API to access and store your login info in the existing, local Windows Credential Store.

You can see the stored credentials by going to Control Panel → User Accounts → Credential Manager and choosing "Windows Credentials". The entries starting "git:" are from git-credential-winstore.

You can set up wincred per repository by:

(GUI)

  1. Navigate to the repository in File Explorer.
  2. Context-click → TortoiseGit → Settings → Git → Credential
  3. Credential helper: wincred - this repository only
  4. The next time you authenticate with the repo, the credentials will be stored.

(CLI, POSH)

  1. cmdkey /add:git:https://USERNAME@github.com /user:USERNAME /pass:PASSWORD
  2.  

    @"
    [credential]
            helper = wincred
    "@ | Out-File -FilePath $repoRoot\.git\config -Append
    

You can list all credentials stored for repos with cmdkey /list:git:*
Once stored, passwords are not displayed by cmdkey (http://ss64.com/nt/cmdkey.html)

To list all credentials with passwords you need to use the Windows API. For powershell, there's CredMan:

. .\CredMan.ps1
.\CredMan.ps1 -ShoCred
adam
  • 279
  • 1
  • 4
  • 11
3

What I did to fix this (windows):

  1. Open PuttyGen import my ssh key and convert it into a putty key, save both public and private parts in the .ssh folder (%userprofile%.ssh)
  2. Open Putty and go to Connection->SSH->Auth then set your private key file there.
  3. Go back to Session, select Default Settings and hit Save.
  4. Now try to clone again and you will be asked for the passphrase on your ssh key, enter it and it should work.
Razze
  • 4,124
  • 3
  • 16
  • 23
3

The URL and the window title TortoisePlink both indicate that tortoise are trying to use ssh as the transport protocol. git support more than one transport protocol, including file system access, and ssh access. In your question, you are describing that you want to access your remote repo by file system access. In that case your remote url should look something like file://server/path/to/repo. Please check your remote repo URL again.

Dov Grobgeld
  • 4,783
  • 1
  • 25
  • 36
2

Pramodtech's answer stopped working for me with the current version of the official Windows Git client. It stores the ssh executable in Git\usr\bin instead of Git\bin now (since version 2.5 released in Aug 2015).

So go to TortoiseGit > Settings > Network and change the SSH client path to:

C:\Program Files\Git\usr\bin\ssh.exe (or whatever the path to your Git installation is)

enter image description here

DerVO
  • 3,679
  • 1
  • 23
  • 27
2

Tortoise GIT DOS command line stopped asking for my password once I placed my private and public keys in C:\Users\.ssh dir. I am on Windows 7.

SunilJ
  • 101
  • 1
  • 3
2

I just face a similar problem today and was able to fix it installing the latest version of git from https://git-scm.com/download/win

Erick Lanford Xenes
  • 1,467
  • 2
  • 20
  • 34
1

Unfortunately, on my machine with Windows 8 the solution with repointing SSH client didn't work. Solution that solved the problem for me is here: http://www.munsplace.com/blog/2012/07/27/saving-username-and-password-with-tortoisegit/

Yevgen Safronov
  • 3,977
  • 1
  • 27
  • 38
  • Please just don't post links add some context: http://meta.stackexchange.com/questions/8231/are-answers-that-just-contain-links-elsewhere-really-good-answers – icc97 Jun 17 '13 at 12:24
  • It is the same answer that Anthony Keane gave above. – rakensi Oct 29 '13 at 07:09
1

Since non of the solutions provided here worked for me, and after a lot disappointments with solutions I found online I finally managed to fix this on my machine.

I don't know when or how I set up my TortoiseGit putty to always use one specific key, and of course this made all the problems when I tried to connect to different server with new pair of keys.

So how to fix a problem and how to tell if you actually have same problem as I had:

  1. Download plink.exe on your machine from here
  2. Open windows command prompt in a same directory where you downloaded your plink.exe
  3. Run this command: plink -v <path_to_your_git_clone_repo_link>
  4. Look at the output and see if you have line like Reading private key file "C:\Path\To\Some\privateKey.ppk"
  5. If you see line like this, and it is not putty key file you want to use then just go and rename/delete/move that file so that plink cant load it next time
  6. After you renamed problematic file it should all work as expected, if you run command from point 3. you should see that plink now cant load that ppk file and after that it should output something like Pageant is running. Requesting keys. and we actually wanted this

That is it, if anyone knows how I can disable this "global default putty key" please let me know in the comments and I'll update this answer with the info.

sbgoran
  • 3,451
  • 2
  • 19
  • 30
1

Please not the URL of the repo remote origin can cause this problem. I had an old repo that worked perfectly and a new one I just cloned that was asking me for password.

Upon comparing the information in Settings > Git > Remote > Url I saw that the one which worked had:

git@github.com:githubAccount/repoName.git

The new one that did not work had an https address.

Please see screenshot below as well.

enter image description here

Menelaos
  • 23,508
  • 18
  • 90
  • 155
1

Had the same problem. In my case there was no password I could enter there. The connection was configured as SSH but there were no keys defined for repo.

Check out: TortoiseGIT SSH configuration. Those instructions are for cloudforge, but for other services you have to do the same, just provide your public key to your git repository provider.

Krzysiek
  • 185
  • 1
  • 10
0

Uninstall Tortoisegit app Do fresh install

  • Initial steps click Next, until Finish
  • Under start wizard step, in the drop-down list give OpenSSH option
  • Then click Finish

Now your Tortoise is not asking for "login as"

Alexandre Jacob
  • 2,993
  • 3
  • 26
  • 36