可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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@youremail.com" 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?
回答1:
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.
回答2:
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@youremail.com"
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
回答3:
I followed below in windows (With Git for Windows installed)
- Run "Git Gui" (Start --> Git --> Git Gui)
- Click Help and then Show SSH Key
- 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\
![](https://www.manongdao.com/static/images/pcload.jpg)
回答4:
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
回答5:
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
回答6:
If you have installed Git, and is installed at C:\Program Files, follow as below
- Go to "C:\Program Files\Git"
- Run git-bash.exe, this opens a new window
- In the new bash window, run "ssh-keygen -t rsa -C""
- It prompts for file in which to save key, dont input any value - just press enter
- Same for passphrase (twice), just press enter
- id_rsa and id_rsa.pub will be generated in your home folder under .ssh
回答7:
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)
回答8:
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)
回答9:
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 "example@example.com"
this should must work.
回答10:
You probably should check this. Windows doesn't have that command built in.
回答11:
For windows you can add this:
SET PATH="C:\Program Files\Git\usr\bin";%PATH%
回答12:
I got it fixed by just adding ssh-keygen
to my environment variables.
回答13:
for those who does not choose BASH HERE option. type sh in cmd then they should have ssh-keygen.exe accessible
回答14:
In my machine, ssh-keygen
was available from powershell.