How to solve Permission denied (publickey) error w

2018-12-31 18:35发布

I'm on Mac Snow Leopard and I just installed git.

I just tried

git clone git@thechaw.com:cakebook.git

but that gives me this error:

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

What am I missing?
I've also tried doing ssh-keygen with no passphase but still same error.

30条回答
冷夜・残月
2楼-- · 2018-12-31 18:38

On Windows, make sure all your apps agree on HOME. Msys will surprisingly NOT do it for you. I had to set an environment variable because ssh and git couldn't seem to agree on where my .ssh directory was.

查看更多
路过你的时光
3楼-- · 2018-12-31 18:38

I was getting this error because I generated the ssh keys with the wrong email. I was able to connect using ssh, but not using git. The solution was to regenerate the keys using the main email address of my github account.

查看更多
只靠听说
4楼-- · 2018-12-31 18:39

This works for me:

ssh-add ~/.ssh/id_rsa
查看更多
看风景的人
5楼-- · 2018-12-31 18:39

Its pretty straight forward. Type the below command

ssh-keygen -t rsa -b 4096 -C "youremailid@yourdomain.com"

Generate the SSH key. Open the file and copy the contents. Go to GitHub setting page , and click on SSH key . Click on Add new SSH key, and paste the contents here. That's it :) You shouldn't see the issue again.

查看更多
笑指拈花
6楼-- · 2018-12-31 18:39

I was getting a similar Permission denied (publickey) error when trying to run a makefile.

As an alternative to the SSH steps above, you can Install the native GitHub for Mac application.

Click Download GitHub for Mac from - https://help.github.com/articles/set-up-git#platform-mac

Once you complete setup with your git hub account (I also installed the git hub command line tools but unsure if this step is required or not) then I received an email -

[GitHub] A new public key was added to your account

and my error was fixed.

查看更多
ら面具成の殇う
7楼-- · 2018-12-31 18:39

It worked for me

ssh -i [your id_rsa path] -T github@github.com
查看更多
登录 后发表回答