OmChoudhary
OmChoudhary

Reputation: 139

Git Bash - ssh-keygen not working (quits before generating RSA key pair)

It's working fine with Eclipse default git extension and I can do each and every operation using it, I can even generate RSA key.

But when I access git remote using git bash, I got this error:

The authenticity of host '[hostname]:PORT ([IP Address]:PORT)' can't be established.
RSA key fingerprint is SHA256:U...M.
Are you sure you want to continue connecting (yes/no)? fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.

and then I removed existing RSA key and tried to generate new RSA key pair and its starts and then quits before completion.

ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/userName/.ssh/id_rsa):
userName@example MINGW64 ~/git/path (branch name):

And I also tried to generate a new RSA key using GIT GUI, I got below error

error writing "stdout": broken pipe
error writing "stdout": broken pipe
    while executing
"puts $::answer"
    (procedure "finish" line 9)
    invoked from within
"finish"
    invoked from within
".b.ok invoke"
    ("uplevel" body line 1)

Thanks in advance.

Upvotes: 1

Views: 5948

Answers (1)

VonC
VonC

Reputation: 1327034

If you are using a recent version of Git (2.19.2 or more), make sure to generate a PEM private SSH key, not an OPENSSH one.
See "Jenkins: what is the correct format for private key in Credentials"

Use:

ssh-keygen -m PEM -t rsa -P "" -f afile

Then try again your git push, from a simple CMD (no need for bash), using a simplified PATH:

set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
set GH=C:\path\to\git
set PATH=%GH%\bin;%GH%\usr\bin;%GH%\mingw64\bin;%PATH%

Upvotes: 2

Related Questions