windows 'ssh-keygen' 未被识别为内部或外部命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11771378/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
'ssh-keygen' is not recognized as an internal or external command
提问by user1567909
I run git push -u origin master
我跑 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?
然后我在网上查了一下,发现我必须为我在 GitHub 上的帐户生成一个 ssh 密钥。但是,这样做后,当我尝试执行 ssh-keygen -t rsa "[email protected]" 时,它只是说无法识别 ssh-keygen。我尝试做 mkdir C:\ssh 但这没有用。如果它有帮助,我正在使用 Ruby Rails 并且我在 Windows 计算机上。有人可以帮助我吗?
回答by VonC
2012:ssh-keygen.exe
is part of msysgit:
2012 年:ssh-keygen.exe
是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
.
如果您%PATH%
包含C:\path\to\msysgit1.7.11\bin\
,您将拥有ssh-keygen
.
Update 2015:ssh-keygen.exe
is part of Git For Windows, whose releasesinclude PortableGit-2.4.3.1-2nd-release-candidate-64-bit.7z
2015 年更新:ssh-keygen.exe
是Git For Windows 的一部分,其版本包括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
)
这意味着%PATH%
必须包括c:\path\to\PortableGit-2.4.3.1-2nd-release-candidate-64-bit\usr\bin
(没有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.
正如我之前所解释的,Windows 版 Git 将很快淘汰 msysgit。
我在“为什么如果你从网上下载 Git 2.0,你总是得到一个 1.9.4 安装程序包?”中详细说明了这个新版本是如何基于最近的msys2 项目的。
回答by cjaypierson
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 并在添加 -C 的情况下运行相同的命令,因为您在电子邮件地址中发表评论: ssh-keygen -t rsa -C "[email protected]"
命令。就是这样。
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
安装 git 时应该已经安装了 git-bash。如果找不到,可以检查 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
我第一次这样做时,它无法为我创建 .ssh 文件夹,所以我不得不打开一个标准的命令提示符和 mkdir C:\Users\yourusername\.ssh
回答by Dinesh Rajan
I followed below in windows (With Git for Windows installed)
我在windows下面跟着(安装了Git for Windows)
- Run "Git Gui" (Start --> Git --> Git Gui)
- Click Help and then Show SSH Key
- Click Generate Key if you do not have one already
- 运行“Git Gui”(开始 --> Git --> Git Gui)
- 单击帮助,然后显示 SSH 密钥
- 如果您还没有,请单击生成密钥
Note:- this creates the key files under your personal profile folder C:\Users\YourUserID\.ssh\
注意:- 这会在您的个人配置文件文件夹 C:\Users\YourUserID\.ssh\ 下创建密钥文件
回答by pirgauthier
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
在命令提示符下,转到您的 git\bin 目录,然后从这里执行您的命令
回答by Bilton Tran
回答by user3233126
If you have installed Git, and is installed at C:\Program Files, follow as below
如果您已经安装了 Git,并且安装在 C:\Program Files,请按照以下步骤操作
- 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
- 转到“C:\Program Files\Git”
- 运行 git-bash.exe,这会打开一个新窗口
- 在新的 bash 窗口中,运行“ssh-keygen -t rsa -C”
- 它会提示保存密钥的文件,不要输入任何值 - 只需按 Enter
- 密码短语相同(两次),只需按 Enter
- id_rsa 和 id_rsa.pub 将在您的主文件夹中的 .ssh 下生成
回答by Vlad
Just go to heroku.bat and add:
只需转到 heroku.bat 并添加:
@SET PATH="D:\Program Files (x86)\Git\bin";%PATH%
after @SET PATH=%HEROKU_RUBY%;%PATH%
@SET PATH="D:\Program Files (x86)\Git\bin";%PATH%
后 @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)
在我的情况下,它在 D:\Program Files (x86)\Git\bin 中,将其更改为您安装 Git 的路径。(我只是把它留在了我的路径中,所以如何写这个会更清楚)
回答by Osama Saeed
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.
这应该有效。
回答by Nehal J Wani
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)
我认为您可以在PATH环境变量中添加文件ssh-keygen.exe的位置。按照步骤操作:转到我的电脑->右键单击->属性->高级系统设置->单击环境变量。现在单击 PATH,然后单击 EDIT。在变量值字段中,转到末尾并附加 ';C:\path\to\msysgit1.7.11\bin\ssh-keygen.exe'(不带引号)