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

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?

This question is related to windows git ssh github

The answer is


I followed below in windows (With Git for Windows installed)

  1. Run "Git Gui" (Start --> Git --> Git Gui)
  2. Click Help and then Show SSH Key
  3. Click Generate Key if you do not have one already

Note:- this creates the key files under your personal profile folder C:\Users\YourUserID\.ssh\

enter image description here


For windows you can add this:

SET PATH="C:\Program Files\Git\usr\bin";%PATH%

don't do anything just type in your command prompt

C:\> sh

then you got like this

sh-4.4$ 
# type here 
ssh-4.4$ ssh-keygen -t rsa -b 4096 -C "[email protected]"

this should must work.


ssh-keygen is a utility usually found on Linux distributions. You can use Cygwin on Windows to have most functionality of the Linux command line available to you.

http://www.cygwin.com/


for those who does not choose BASH HERE option. type sh in cmd then they should have ssh-keygen.exe accessible


I got it fixed by just adding ssh-keygen to my environment variables.


for all windows os

cd C:\Program Files (x86)\Git\bin
ssh-keygen

Are you running msysgit, or some other form of Windows git installation? msysgit is only one possible way to run git on Windows but it's probably also the simplest one. It's also the way recommended by the git website at http://git-scm.org/ .

If you are using msysgit, then you need to run the command in Git Bash, not in a standard Windows command line prompt. Git Bash is a prompt that is installed for you by msysgit, and is basically the most common Linux command line shell (bash) packaged for Windows to facilitate command line usage of git. msysgit should also install the ssh-keygen program in a place where it is accessible from Git Bash, but not necessarily from your usual Windows command line prompt.


You probably should check this. Windows doesn't have that command built in.


Just go to heroku.bat and add:

@SET PATH="D:\Program Files (x86)\Git\bin";%PATH% after @SET PATH=%HEROKU_RUBY%;%PATH%

in my case it's in D:\Program Files (x86)\Git\bin, change it to the path you've installed Git to. (i just left it with my path so it will be clearer on how to write this)


if you run from cmd on windows check the path System Variable value must have inside C:\Program Files\Git\bin or the path of you git installation on cmd type set to see the variables


If you previously installed Git, open a git-bash and try the command from there.


Search your git directory if you already install git

Use git bash should be on your C:\Program Files\Git\bin depend on your installation location

If you already add the path just run sh on your cmd or open sh.exe

type ssh-keygen

Then just insert name and passphrase (You can just type empty string).


I just had this issue and thought I'd share what I thought was an easier way around this.

Open git-bash and run the same command with the addition of -C since you're commenting in your email address: ssh-keygen -t rsa -C "[email protected]" command. That's it.

git-bash should have been installed when you installed git. If you can't find it you can check C:\Program Files\Git\Git Bash

The first time I did this it failed to create the .ssh folder for me so I had to open a standard Command Prompt and mkdir C:\Users\yourusername\.ssh


  • Install msysgit
  • Right-click on any file
  • Select "Select Git Bash here" from menu
  • Run ssh-keygen command from a git bash terminal

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.


If you have installed Git, and is installed at C:\Program Files, follow as below

  1. Go to "C:\Program Files\Git"
  2. Run git-bash.exe, this opens a new window
  3. In the new bash window, run "ssh-keygen -t rsa -C""
  4. It prompts for file in which to save key, dont input any value - just press enter
  5. Same for passphrase (twice), just press enter
  6. id_rsa and id_rsa.pub will be generated in your home folder under .ssh

STEP 1 Install Git.

STEP 2 Add the path of your git to the environment variables like this C:\Program Files (x86)\Git\bin.

STEP 3 Open new terminal session and try ssh-keygen. It will work.

NOTE New Terminal Window is must!


No need to add anything to environmental variables! Just open up git bash and perform command the ssh-keygen in there.

Link to download git bash here


I think you can add the location of the file ssh-keygen.exe in the PATH environment variable. Follow the steps: Go to My Computer->Right click->Properties->Advanced System Settings->Click Environmental Variables. Now click PATH and then click EDIT. In the variable value field, go to the end and append ';C:\path\to\msysgit1.7.11\bin\ssh-keygen.exe' (without quotes)


I found an easy solution to fix this :

In the command prompt, go to your git\bin directory, and then execute your commands from here


In my machine, ssh-keygen was available from powershell.


Running git bash as an admin worked for me!


Examples related to windows

"Permission Denied" trying to run Python on Windows 10 A fatal error occurred while creating a TLS client credential. The internal error state is 10013 How to install OpenJDK 11 on Windows? I can't install pyaudio on Windows? How to solve "error: Microsoft Visual C++ 14.0 is required."? git clone: Authentication failed for <URL> How to avoid the "Windows Defender SmartScreen prevented an unrecognized app from starting warning" XCOPY: Overwrite all without prompt in BATCH Laravel 5 show ErrorException file_put_contents failed to open stream: No such file or directory how to open Jupyter notebook in chrome on windows Tensorflow import error: No module named 'tensorflow'

Examples related to git

Does the target directory for a git clone have to match the repo name? Git fatal: protocol 'https' is not supported Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) git clone: Authentication failed for <URL> destination path already exists and is not an empty directory SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 GitLab remote: HTTP Basic: Access denied and fatal Authentication How can I switch to another branch in git? VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio?

Examples related to ssh

Starting ssh-agent on Windows 10 fails: "unable to start ssh-agent service, error :1058" How to solve "sign_and_send_pubkey: signing failed: agent refused operation"? key_load_public: invalid format ssh connection refused on Raspberry Pi Getting permission denied (public key) on gitlab Verify host key with pysftp Can't connect to Postgresql on port 5432 Checkout Jenkins Pipeline Git SCM with credentials? How to open remote files in sublime text 3 how to setup ssh keys for jenkins to publish via ssh

Examples related to github

Does the target directory for a git clone have to match the repo name? Issue in installing php7.2-mcrypt How can I switch to another branch in git? How to draw checkbox or tick mark in GitHub Markdown table? How to add a new project to Github using VS Code git clone error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054 How to add empty spaces into MD markdown readme on GitHub? key_load_public: invalid format git - remote add origin vs remote set-url origin Cloning specific branch