0

Step 1: Generating SSH Key

1.From the command line, enter ssh-keygen. (if you get an error in the command window, check if C:\Program Files\Git\usr\bin is part of your path) The command prompts you for a file to save the key in

  1. Press enter to accept the default key and path, /c/Users//.ssh/id_rsa.

  2. Enter and re-enter a passphrase when prompted.

  3. The command creates your default identity with its public and private keys.

2.Configuring tortoise-git

  1. Load the ssh key generated previously(id_rsa). it will prompt you to select the file. (default path of the ssh keys C:\Users\.ssh)

  2. While loading it will ask for passphrase.. enter the passphrase that was given earlier. After this step putty will load the certificate.

  3. Once the certificate is loaded, click on the 'Save private key' button. it will prompt for picking the folder in which the file to be saved. Better to keep it in the same one as ssh key folder (C:\Users\.ssh). specify the filename also.

  4. Now you have to configure the TortoiseGit with the generated key file. right click on the repo folder select TortoiseGit>Settings

  5. In the settings screen select Git > Remote

  6. In remote screen, select origin.. it will populate the URL and other fields.

  7. Click on the ellipses against the Putty Key field and select the private key file that was generated with puttygen.

The file format of the private key is

----BEGIN RSA PRIVATE KEY------

xxxxxxxyyxyyxyxyxy

----END RSA PRIVATE KEY------- enter image description here

Gitsetting

The error was

Couldn't load private key(unable to open file)

enter image description here The file has read-write permission. Apart from this private key has a passphrase, I think it would be the reason for the error.

The public key configuration in my bitbucket account, Public key setting

  • By "I had generated a private key in puttygen" - do you mean that you have converted the key from PEM format to PPK? – Martin Prikryl Mar 6 '18 at 8:55
  • Yeah, I converted it to .ppk file. – kvk30 Mar 6 '18 at 8:56
  • Well, so edit your question to make that clear. Your current wording is nonsense. – Martin Prikryl Mar 6 '18 at 8:59
  • Explain how did you convert the key. + Show us how does the converted .ppk file look like + "The error was" - What error? When do you get that error? + – Martin Prikryl Mar 6 '18 at 9:00
  • Attached screenshots and steps what I had followed to configure git and generating keys. – kvk30 Mar 6 '18 at 9:10
5

If I understand you correctly, you didn't use puttygen to create a keypair, instead, you used ssh-keygen to generate a keypair with passphrase, then you loaded that private key into Putty and saved it as Putty.ppk and got the error Couldn't load Private Key (cannot open file).

What format was the private key (id_rsa) you created in?

If you open it in a text file is the first like similar to this:

-----BEGIN RSA PRIVATE KEY-----

or does it look like this:

ssh-rsa AWEdxRASFLMAF......

This appears to be, likely, an issue with you loading the public key instead of the private key to save as a .ppk. The screenshot you show has 2 files: id_rsa and id_rsa, but one of them is the private key file and the other is the public key. It's probable that you selected the public key if no file extensions were shown. Try re-importing the key by selecting the id_rsa file with the timestamp of 05-03-2018 12:36 in your screenshot above.

Verify the first line in that file is

-----BEGIN RSA PRIVATE KEY-----

before you do.

  • Updated my question, It looks similar way as you said but the error is still reflecting. can you please help me in further? – kvk30 Apr 3 '18 at 18:32
  • have you uploaded your public key to your remote git repository yet? – Timmy Browne Apr 3 '18 at 19:03
  • I had set public key for my bitbucket account still same error no change in the error message. – kvk30 Apr 4 '18 at 6:29
  • your screenshots are changing as is the value of the key in the putty key field. This is very confusing. What happened if you run the git push command outside of tortoise, does it work or do you get an error? whats the value of Settings - TortoiseGit >> Network >> SSH-Client? you originally appeared to state that you generated a keypaid (id_rsa / id_rsa.pub) . imported it into putty by converting it to putty.ppk . and were having trouble reading the key, which you had then set up in tortoise. now you are showing you are using id_rsa as the key in tortoise. – Timmy Browne Apr 4 '18 at 13:41
  • My screenshots are updated to give clarity, I tried as mentioned in comments. To ensure my trying, I am updating screenshots. By command-line, I am not getting an error. You mentioned in your answer that private key has some format, which is id_rsa, so updated key to id_rsa from putty.gen. Sorry for making you confused, I am unable to show the root cause or problem. Showing my whole procedure for clarity. – kvk30 Apr 5 '18 at 5:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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