Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法在Windows 7中为heroku生成ssh公钥_Heroku_Ssh_Public Key_Heroku Toolbelt - Fatal编程技术网

无法在Windows 7中为heroku生成ssh公钥

无法在Windows 7中为heroku生成ssh公钥,heroku,ssh,public-key,heroku-toolbelt,Heroku,Ssh,Public Key,Heroku Toolbelt,当我尝试在我的机器中通过cmd登录heroku时,它说 找不到现有公钥 是否要生成一个?[YN] 之后,当我按“y”并输入时,它会显示 正在生成新的ssh公钥 无法生成密钥:“ssh keygen”未被识别为内部或外部命令可操作程序或批处理文件 请帮助我。Heroku toolbelt包括git发行版,其中包括所需的ssh-keygen.exe。我刚刚在C:\Program Files\git\bin中找到了它。找到您的git文件夹,并将其添加到您的系统路径中,如下所述:我遇到了相同的问题,刚刚

当我尝试在我的机器中通过cmd登录heroku时,它说

找不到现有公钥
是否要生成一个?[YN]

之后,当我按“y”并输入时,它会显示

正在生成新的ssh公钥
无法生成密钥:“ssh keygen”未被识别为内部或外部命令可操作程序或批处理文件


请帮助我。

Heroku toolbelt包括git发行版,其中包括所需的ssh-keygen.exe。我刚刚在C:\Program Files\git\bin中找到了它。找到您的git文件夹,并将其添加到您的系统路径中,如下所述:

我遇到了相同的问题,刚刚解决了它。我安装了另一个名为gitbash的CMD,您可以免费下载它(),然后重复了其中的命令,它成功了

对于Win7 64位用户,文件
%HerokuPath%s\bin\ssh keygen.bat
如下所示:

@SETLOCAL
@SET HOME=%USERPROFILE%
@"%HerokuPath%\..\Git\bin\ssh-keygen.exe" %*
但是Heroku在
程序文件(x86)
中安装Git,因此如果将
.bat
文件更新为:

@SETLOCAL
@SET HOME=%USERPROFILE%
@"C:\Program Files (x86)\Git\bin\ssh-keygen.exe" %*
然后您应该能够生成ssh密钥。

Windows 10-64位

我安装了git,然后是heroku toolbelt(我认为它重新安装了git)

我的环境变量中有
C\Program Files(x86)\Heroku\bin
(可能是在我安装Heroku toolbelt时生成的),如果我查看该文件路径,我就有一个ssh-keygen.bat-因此看起来我应该可以从命令行运行
ssh-keygen-t rsa

这太简单了,我得到的是:

C:\Program Files (x86)\Git\bin>ssh-keygen -t rsa -f id_rsa
'"C:\Program Files (x86)\Heroku\..\Git\bin\ssh-keygen.exe"' is not recognized as an internal or external command,
operable program or batch file.
解决方案

在命令行中键入
bash
进入git-bash模式,然后运行
ssh-keygen-t rsa

git bash:

mamwo@DESKTOP-9GVG6K8 MINGW32 /bin
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/mamwo/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/mamwo/.ssh/id_rsa.
Your public key has been saved in /c/Users/mamwo/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:MMMYYYPPPUUUBBBLLIIICCKKEEEEYYYY mamwo@DESKTOP-9GVG6K8
The key's randomart image is:
现在,当我查看C/User/mamwo/.ssh(对我来说最好的方法是通过pycharms文件夹-windows很糟糕)时,我看到了我的id\u rsa和id\u rsa.pub

但这个“无法生成公钥”的问题都是从我开始的,因为当我将我的repo(从github)克隆到一台新计算机上时,我遇到了一个“我没有要添加的公钥”的问题,我发现我可以推到github,但不能推到heroku

现在我有了钥匙,我必须把它们加进去

C:\Users\mamwo\Desktop\mv>git push heroku master
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

C:\Users\mamwo\Desktop\mv>heroku keys
You have no keys.

C:\Users\mamwo\Desktop\mv>heroku keys:add
Found an SSH public key at C:/Users/mamwo/.ssh/id_rsa.pub
Would you like to upload it to Heroku? [Yn]

请参阅前面的答案:@user2098336选择解决您的问题的解决方案,以帮助其他程序员在未来面临相同问题,这将是非常重要的!我很确定heroku工具带现在包括git bash,即使在文章发表时没有。但是,是的,我犯了同样的错误,像习惯一样直接选择CMD——同样的错误。因为我已经有了git bash,尝试了一下,效果非常好!谢谢。根据对另一个答案的评论,由于这是投票最多的(因为这是正确的),我要注意:如果您使用git bash CLI使用
heroku auth:login
登录heroku,您将能够生成SSH密钥。如果在windows上使用相同命令的普通
cmd
shell,则需要在路径中包含Git目录;这种行为的原因是,根据目前的情况,Git bash在运行时设置了路径。@ChrisCirefice谢谢!在我的Win 10中,它位于C:\Program Files\Git\usr\bin!