60

I am trying to add ssh keys for usage on github but on my xp on command prompt ssh-keygen does not work. It gives me the following error

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

Is there an alternative for generating keys on xp?

Neeraj Kumar
  • 771
  • 2
  • 16
  • 37
pal4life
  • 3,210
  • 5
  • 36
  • 57

10 Answers10

53

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.

kini
  • 1,781
  • 13
  • 23
42

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!

sud007
  • 5,824
  • 4
  • 56
  • 63
ajknzhol
  • 6,322
  • 13
  • 45
  • 72
  • 3
    Very helpful. Nice precise Answer! DO not forget to open the NEW CMD WINDOW! – sud007 Oct 21 '15 at 09:17
  • 2
    sometimes git might be installed in **C:\Program Files\Git\bin** so verify the git existence and add the path. – unknownerror Sep 07 '16 at 02:47
  • 21
    In my case the "ssh-keygen.exe" was placed under user folder i-e. C:\Program Files\Git\usr\bin – Muhammad Sep 24 '16 at 12:27
  • I've add the `C:\Program Files\Git\bin` to the `System Environment Variable\Path` https://imgur.com/xVWwqew , but it still doesn't work. in the `C:\Program Files\Git\bin` there is no `ssh-keygen.exe` https://imgur.com/al12otX . Do you know What's my problem and how can I fix it? Thanks! – Luke Jun 14 '18 at 17:42
22

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

ScottLenart
  • 1,160
  • 1
  • 12
  • 15
9

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).

3

Running git bash as an admin worked for me!

Mansi
  • 89
  • 4
2

for all windows os

cd C:\Program Files (x86)\Git\bin
ssh-keygen
Arif Acar
  • 1,461
  • 2
  • 19
  • 33
1
  • Install msysgit
  • Right-click on any file
  • Select "Select Git Bash here" from menu
  • Run ssh-keygen command from a git bash terminal
Kondal Kolipaka
  • 3,471
  • 22
  • 28
0

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

Sotos
  • 416
  • 4
  • 4
0
C:\Program Files\Git\usr\bin

Add this to the envvars and reopen cmd. Thats it.

SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
-1

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/

thezboe
  • 552
  • 1
  • 5
  • 13
  • But the ssh command works on my command prompt on Windows 7? Also wondering would cygwin in any way conflict with git? – pal4life Apr 13 '12 at 18:37
  • You must have installed openssh client or something like it to be able to use it with the Windows 7 command prompt. Cygwin won't conflict with git, you should be able to use git in Cygwin and the command prompt at any time. You might even find that Cygwin is a lot easier to deal with than the CP. – thezboe Apr 13 '12 at 18:40
  • Pardon me but it is very complicated to install Cygwin, would there be another alternative? – pal4life Apr 13 '12 at 19:19
  • 1
    Eclipse can generate key-pair in pure Java. Window > Preferences > General > Network Connections > SSH2 – ymnk Apr 13 '12 at 23:57