1

I have a problem with SSH key usage for GIT on windows. It works fine from windows GUI git clients. From the terminal - git-bash / mingw32 - it fails with

$ git pull
git@<gitserver redacted>: Permission denied (publickey).
fatal: Could not read from remote repository.

I have run eval "$(ssh-agent -s)" and ssh-add ~/.ssh/2025-my-PRIVATE-key.ppk but to no avail.

My key content is of the form

$ cat ~/.ssh/2025-my-PRIVATE-key.ppk
PuTTY-User-Key-File-3: ssh-rsa
Encryption: aes256-cbc
Comment: rsa-key-2025-testing
Public-Lines: 6
REDACTED
...
REDACTED
Key-Derivation: REDACTED
...
Private-Lines: 14
REDACTED
...
Private-MAC: REDACTED
2
  • I’m voting to close this question because it's blatantly off-topic as question for software run on windows (and not within a Unix/Linux VM). Commented Oct 20 at 19:57
  • i'm not running a vm, but git-bash for windows, but i get the sentiment Commented Oct 22 at 18:50

1 Answer 1

2

my private key is .ppk format.

This is fine for the GUI git client on windows, but won't work with the bash like terminal git-bash / mingw32.

The problem is that the .ppk format is PuTTY's native format and will not work directly with OpenSSH tooling which expects OpenSSH format.

To use the key in the git-bahsh environment, I have to export an openssh compatible version.

Based on this anwser by @workabyte (and really the call-out comment by klor which is what caught my eye), I tried opening and re-exporting the private key for use with git-bash and that was fine.

Detail

  1. opened the "PuTTyGen" app (PuTTY Key Generator)
  2. used the "Load" button and selected my private key
  3. select menu item Conversions -> Export OpenSshKey and save the file as a new name
    • the openSSH file extension is typically .pem, .key or no extension.
    • i chose .pem

Then from the shell i can run:

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/2025-my-PRIVATE-key.pem
git pull

and get good connection and output:

Agent pid 2376
Enter passphrase for /c/Users/mud/.ssh/2025-my-PRIVATE-key.pem:
Identity added: /c/Users/mud/.ssh/2025-my-PRIVATE-key.pem (/c/Users/mud/.ssh/2025-my-PRIVATE-key.pem)
Already up to date.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.