Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git Permission denied (publickey)

Tags:

git

I met some problem when I want to set up ssh to my git. Here is the error message I got.

mbp-op-159:.ssh weiting.cheng$ ssh -vT [email protected]
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to github.com [192.168.1.1] port 22.
debug1: Connection established.
debug1: identity file /Users/c/.ssh/id_rsa type 1
debug1: identity file /Users/c/.ssh/id_rsa-cert type -1
debug1: identity file /Users/c/.ssh/id_dsa type -1
debug1: identity file /Users/c/.ssh/id_dsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version libssh-0.7.0
debug1: no match: libssh-0.7.0
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-sha1 none
debug1: kex: client->server aes128-ctr hmac-sha1 none
debug1: sending SSH2_MSG_KEXDH_INIT
debug1: expecting SSH2_MSG_KEXDH_REPLY
debug1: Server host key: RSA     16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /Users/c/.ssh/known_hosts:2
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/c/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/c/.ssh/id_dsa
debug1: No more authentication methods to try.
Permission denied (publickey).

I followed the instruction on the git hub document, but they didn't mentioned my problem.

I have private key

debug1: identity file /Users/c/.ssh/id_rsa type 1

I also add the key to my git hub account

git success get the my private key

debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/c/.ssh/id_rsa

But for the unknown reason git keep going on id_dsa which I didn't generate it.

debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/c/.ssh/id_dsa
debug1: No more authentication methods to try.

Then I got permission denied.

anyone has suggestion to solve this issue?

like image 566
waitingduck Avatar asked Oct 30 '22 15:10

waitingduck


1 Answers

Your key isn't valid. I'd recommend starting over entirely, so go ahead and delete everything in your ~/.ssh/ folder (except for known_hosts, you should probably keep that). Then run:

ssh-keygen -t rsa -b 4096 -C "[email protected]"

Use the email address associated with your GitHub account. Be sure the key is being saved in the right user's folder. In your case the key should be saved as /Users/c/.ssh/id_rsa.

Finally, copy the contents of ~/.ssh/id_rsa.pub to your clipboard. Go to your GitHub settings, click on the SSH Keys tab, and add the key you just copied.

I'm sure you looked at this already, but here's a more detailed walkthrough.

like image 60
nick Avatar answered Nov 15 '22 03:11

nick