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

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


The thing is your PuTTy uses ssh v2 (and it's good) but you key is generated for version 3 probably.

Here the steps to verify: enter image description here

enter image description here

After you click OK, generate a new key and try to upload it. Worked for me.


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.