問題描述
之前一直使用的 SourceTree 來推送的代碼到 gitee 倉庫的突然一天不能推送了,說是沒有權限,確認過本地生成 rsa 公鑰加入了倉庫 ssh 配置,所以直接執行第四步,解決問題;
由於TortoiseGit沒有MAC版本,我們使用了SourceTree來替代.
在幫同事解決Mac下的Git的時候,碰到一個問題:
sh-3.2# git clone [email protected]:windss/accounting_tool_products.git
Cloning into 'accounting_tool_products'...
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
解決步驟
-
在用戶目錄下創建.ssh文件夾—已有則跳過
-
生成公鑰和私鑰
命令:ssh-keygen -t rsa -C '[email protected]' -f ~/.ssh/gitee_id_rsa
- 創建cofig文件(任意名稱),存放以下內容
Host mygit
HostName host
Port 22
User git
IdentityFile ~/.ssh/gitee_id_rsa
- 將私鑰加入ssh
sh-3# export PATH=/usr/bin:$PATH
sh-3# ssh-add -K ~/.ssh/gitee_id_rsa
Identity added: /var/root/.ssh/gitee_id_rsa ([email protected])
第一條:將當前的環境變量設置成user/bin,進入/user/bin目錄.
第二條:將密鑰加到ssh中.
第三條:提示成功