解決git提示Permission denied (publickey)
在linux 或 mac os 裝完git黎做,然后clone github的項(xiàng)目時(shí)出問題,報(bào)以下錯(cuò)誤松忍。
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
出現(xiàn)這個(gè)錯(cuò)誤很顯然是ssh key的問題蒸殿。我們只需要跟github官方的配置ssh的流程走一遍就行了。
1.生成SSH Keys
如果已經(jīng)生存了ssh key,那就可以跳過這一步了鸣峭『晁可以用以下命令查看
ls -l ~/.ssh
ls -l ~/.ssh
如果出現(xiàn)id_rsa 和 id_rsa_pub 那就說明已經(jīng)生成。
如果沒有摊溶,按一下步驟生成
ssh-keygen -t rsa -C “your_email@example.com”
下面的步驟爬骤,可以一直都敲回車,如果對(duì)安全性要求很高莫换,就自己輸入密碼吧盖腕。成功后,你會(huì)看到下面的提示:
Your public key has been saved in /Users/you/.ssh/id_rsa.pub.
The key fingerprint is:
01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com
Your identification has been saved in /Users/you/.ssh/id_rsa.
Your public key has been saved in /Users/you/.ssh/id_rsa.pub.
The key fingerprint is:
01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com
Your identification has been saved in /Users/you/.ssh/id_rsa.
2.Key 添加到ssh-agent
ssh-agent 貌似是對(duì)解密的專用密鑰進(jìn)行高速緩存浓镜。在windows 沒有這一步,linux mac os還需要手動(dòng)添加到ssh-agent劲厌。首先確定ssh-agent是否啟用
ssh-agent -s
如果看到Agent pid xxxxx 那就說明已經(jīng)啟用
然后把私鑰添加到ssh-agent就可以了膛薛。
ssh-add ~/.ssh/id_rsa
把公鑰添加到自己的github
這個(gè)過程很簡(jiǎn)單,我簡(jiǎn)略寫一下补鼻。依次進(jìn)入settings–>ssh keys–>add ssh key 然后把你的公鑰添加進(jìn)這里就ok了哄啄。
找了許多解決方法都搞不定,最終還是按照github 官方的流程走通了风范。git 不是linux的親兒子么咨跌,怎么在linux配置比其他平臺(tái)還麻煩,不得不吐槽啊。硼婿。