我用的是Mac雪豹,刚刚安装了git。

我只是试了

git clone git@thechaw.com:cakebook.git

但这给了我这个错误:

Initialized empty Git repository in `/Users/username/Documents/cakebook/.git/`
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

我错过了什么? 我也试过做ssh-keygen没有密码,但仍然错误。


当前回答

更广泛的故障排除,甚至自动修复可以完成:

ssh -vT git@github.com

或者,根据以下意见,我们可以发出:

ssh -vT git@gitlab.com

或者用你的组织正在运行的Git实例替换gitlab/github。

来源:https://help.github.com/articles/error-permission-denied-publickey/

其他回答

我必须将ssh密钥复制到根文件夹。 谷歌云计算引擎,Ubuntu 18.04

sudo cp ~/.ssh/* /root/.ssh/

更广泛的故障排除,甚至自动修复可以完成:

ssh -vT git@github.com

或者,根据以下意见,我们可以发出:

ssh -vT git@gitlab.com

或者用你的组织正在运行的Git实例替换gitlab/github。

来源:https://help.github.com/articles/error-permission-denied-publickey/

基本的GIT指令没有引用SSH密钥之类的东西。沿着上面的一些链接,我发现了一个git帮助页面,它一步一步地解释了如何在各种操作系统上做到这一点(链接将检测您的操作系统并相应地重定向):

http://help.github.com/set-up-git-redirect/

它介绍了GITHub所需的所有内容,并给出了详细的解释,例如“为什么在创建RSA密钥时添加密码短语”。我想我应该把它贴出来,说不定能帮助到别人……

伙计们我是这么干的

Open terminal and go to user [See attached image] Open .ssh folder and make sure it doesn't have any file like id_rsa or id_rsa.pub otherwise sometimes it wont properly rewrite files git --version [Check for git installation and version] git config --global user.email "your email id" git config --global user.name "your name" git config --list [make sure you have set your name & email] cd ~/.ssh ssh-keygen, it prompts for saving file, allow it cat ~/.ssh/id_rsa.pub [Access your public key & copy the key to gerrit settings]

注意:你不应该在Git中使用sudo命令。如果您有非常好的理由必须使用sudo,那么请确保您在每个命令中都使用它(此时使用su作为根来获取shell可能更好)。如果您不使用sudo生成SSH密钥,然后尝试使用sudo git push之类的命令,那么您将不会使用您生成的相同密钥

我碰到了这个错误,因为我需要给我目前的工作目录权限700:

chmod -R 700 /home/ec2-user/