git: 'ssh-keygen' is not a git command. Se

2019-06-14 08:19发布

问题:

I was trying to follow the instructions on GitHub to generate an SSH key so I can push from my laptop to my GitHub account. I'm using Git on Windows 10 with mingw32, and I entered this command in Git Bash (not cmd):

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

This failed with git: 'ssh-keygen' is not a git command. See 'git --help'.

Why would that be and how can I fix it?

回答1:

Make sure of your %PATH% (in a CMD) before entering your git bash session.

If your PATH is correct, then this is what you should see:

vonc@voncvb:/mnt/c$ which ssh-keygen
/usr/bin/ssh-keygen

For testing, set a simplified PATH in your CMD session.

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

Then type bash, to enter a bash shell session.
And try there ssh-keygen.