'ssh-keygen' is not recognized as an internal or external command

user1567909 picture user1567909 · Aug 2, 2012 · Viewed 225k times · Source

I run git push -u origin master

It tells me that "Permission denied (public key) fatal: The remote end hung up unexpectedly"

Then I looked up on the internet and found that I had to generate an ssh key for my account on GitHub. However, upon doing so, when I tried to do ssh-keygen -t rsa "[email protected]" it simply said ssh-keygen is not recognized. I tried doing mkdir C:\ssh but that didn't work. If it helps I'm using Ruby Rails and I'm on a Windows computer. Could anyone help me?

Answer

VonC picture VonC · Aug 2, 2012

2012:
ssh-keygen.exe is part of msysgit:

 C:\path\to\msysgit1.7.11\bin\ssh-keygen.exe

if your %PATH% includes C:\path\to\msysgit1.7.11\bin\, you will have ssh-keygen.


Update 2015:
ssh-keygen.exe is part of Git For Windows, whose releases include PortableGit-2.4.3.1-2nd-release-candidate-64-bit.7z

c:\path\to\PortableGit-2.4.3.1-2nd-release-candidate-64-bit\usr\bin\ssh-keygen.exe

That means the %PATH% must include c:\path\to\PortableGit-2.4.3.1-2nd-release-candidate-64-bit\usr\bin (without the ssh-keygen.exe)

As I explained before, Git for Windows will soon phase out msysgit.
I detailed in "Why is it that if you download Git 2.0 from the net, you always get a 1.9.4 installer package?" how this new version is based on the more recent msys2 project.