1. 程式人生 > >Git使用之Permission Denied問題解決

Git使用之Permission Denied問題解決

it is efault not style 能夠 res star ria 使用

今天碰到了Git的Permission Denied問題。

在安裝好git之後,我們通常會配置username和郵箱

git config --global user.name "zengjinlong" #--global表明本機的全部git倉庫均使用該配置

git config --global user.email "[email protected]"

可是當我們克隆一個庫的時候。發現不論你怎麽輸入password都是說Permission Denied。

事實上,這是你沒有生成公鑰

找到這個頁面:


SSH Keys


SSH key allows you to establish a secure connection between your computer and GitLab


Before generating an SSH key, check if your system already has one by running cat ~/.ssh/id_rsa.pub If your see a long string starting with ssh-rsa or ssh-dsa, you can skip the ssh-keygen step.


To generate a new SSH key just open your terminal and use code below. The ssh-keygen command prompts you for a location and filename to store the key pair and for a password. When prompted for the location and filename you can press enter to use the default. It is a best practice to use a password for an SSH key but it is not required and you can skip creating a password by pressing enter. Note that the password you choose here can‘t be altered or retrieved.


ssh-keygen -t rsa -C "$your_email"


Use the code below to show your public key.


cat ~/.ssh/id_rsa.pub
Copy-paste the key to the ‘My SSH Keys‘ section under the ‘SSH‘ tab in your user profile. Please copy the complete key starting with ssh- and ending with your username and host.

非常easy,就是用你的郵箱生成一個公鑰,然後增加到你的代碼管理站點中。然後在例如以下頁面中增加SSH Key到項目中。

My SSH keys Add SSH Key

SSH keys allow you to establish a secure connection between your computer and GitLab
Before you can add an SSH key you need to generate it


然後再git clone 一次,發現能夠了。好了。這個問題解決。


Git使用之Permission Denied問題解決