当我想要使用这个命令推送到GitHub时
git push origin master
我得到了这个Permission denied (publickey).
fatal: The remote end hung up unexpectedly
那么,出了什么问题?
当我想要使用这个命令推送到GitHub时
git push origin master
我得到了这个Permission denied (publickey).
fatal: The remote end hung up unexpectedly
那么,出了什么问题?
ssh-keygen -t rsa
在生成密钥时,它会提示您(可选)输入要保存的文件名。 指定文件名浪费了我整整一天的时间!第二天我让它使用默认文件名,问题就消失了!想象一下!!
平台是Win7和msysgit。
id_rsa
),那么请确保将其添加到~/.ssh/config
中:IdentityFile ~/.ssh/customname
(将customname
替换为你的密钥名称,不包括.pub
)。在Linux环境中似乎不需要这样做。 - matb33安装完msysgit后,Git Bash也会被安装。有两种方法打开Git Bash:
在Git Bash的命令窗口中输入以下内容:
$ ssh-keygen -t rsa
当要求输入文件名时,只需接受默认值。在提示时选择一个强密码短语,你的公钥应该已经保存。你的屏幕应该看起来像这样:
请在记事本中打开公钥文件。该文件应该位于以下位置:
C:\Users\{username}\.ssh\id_rsa.pub
将文件中的所有内容复制到剪贴板中,然后转到GitHub的SSH设置页面:
https://github.com/settings/ssh
选择“添加SSH密钥”,输入一个有用的“标题”,并将内容粘贴到“密钥”文本框中。$ eval `ssh-agent -s`
$ ssh-add ~/.ssh/id_rsa
当您输入命令时,系统会提示您输入密码。如果一切顺利,您的身份将被添加。请注意:只要关闭shell,此密码就会被遗忘。我不确定如何使其在不同的会话中持久存在,但也许有人可以提供帮助?
为了测试所有功能是否正常,请在Git Bash中输入以下内容:
$ ssh -T git@github.com
您应该看到一个“成功”消息。
来源:
https://help.github.com/articles/generating-ssh-keys/
https://help.github.com/articles/working-with-ssh-key-passphrases/
explanation on why eval `ssh-agent -s` should be used instead of just ssh-agent -s
eval \
ssh-agent -s`` 是关键。我使用这个一行命令来解决问题。 - Ni Xiaoni$ eval \
ssh-agent -s`` - Ni Xiaoni如果出现“Permission denied (publickey)”的提示,您需要为密钥输入密码。不要尝试只是按回车键...这就是我成功的方法...我花了五个小时才意识到按回车键会让OpenSSH觉得您的密钥太公开了,这就是为什么它拒绝让您进行下一步。
如果出现“The authenticity of host 'github.com (203.232.175.90)' can't be established.”的提示,那么您需要按照此处所示的过程进行操作:[Google]。
跳转到 “Verify the public key is attached to your GitHub account” 部分。您需要从account开始阅读。(我假设您已经有一个账户)。
同时,您需要位于C:\RailsInstaller\Git.ssh目录下,并且当我运行'dir'命令时,我发现我有'.', '..', 'known_hosts'文件。我必须通过以下方式获取新密钥(我在Github网站上找到了这个方法):
"ssh-keygen -t rsa -C "your_email@example.com" # 创建一个新的SSH密钥,使用提供的电子邮件作为标签 # Generating public/private rsa key pair. < # 输入要保存密钥的文件(/c/Users/you/.ssh/id_rsa):[按回车键]"
并且需要注意密钥将被保存的文件路径。不要只是按回车键...我的路径显示为“(//.ssh/id_rsa)”我必须输入“/.ssh/id_rsa”以确保它位于正确的目录中。
之后,您就可以在命令行中输入SSH命令。如果您无法这样做,您需要将其添加到您的路径中。
我曾经通过添加系统环境变量解决了一个类似的问题。关键在于我正在指向cmd文件夹中的git.exe。
名称:GIT
值:C:\Program Files (x86)\Git\cmd\git.exe
git.exe
文件?一个在 C:\Program Files (x86)\Git\bin
目录下,另一个在 C:\Program Files (x86)\Git\cmd
目录下。请问有什么原因吗? - AlikElzin-kilakaC:\Program Files (x86)\Git\cmd
而不是\bin
解决了我的问题。 - Ryan RodemoyerName: HOME
Value: %USERPROFILE%
你的Heroku密钥可能存在问题。请尝试以下操作:
heroku keys:add
这是Windows 7的默认输出。
c:\test\app>ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (//.ssh/id_rsa):
Could not create directory '//.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
open //.ssh/id_rsa failed: No such host or network path.
Saving the key failed: //.ssh/id_rsa.
不再使用命令提示符,而是按照http://help.github.com/win-set-up-git/中的说明使用git?
setx GIT_SSH "C:\Program Files (x86)\PuTTY\plink.exe"
。 - karel_evzengithub.com
,然后按回车键,接着您就可以接受该主机了。 - 244an