使用IDEA和GIT利用SSH拉取項目時報如下錯誤:git
git -c core.quotepath=false -c log.showSignature=false pull --progress --no-stat -v --progress origin master
Permission denied, please try again.
git@192.168.1.2: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
複製代碼
先是百度搜了一下,發現全特麼都是複製粘貼,沒法解決問題。仍是google好使。。api
解決辦法:bash
前置:已生成SSH KEYapp
第一步: 修改IDEA的配置,將 Version Control
> Git
> SSH executeable
調整爲Native
,以下圖所示ssh
第二步: 打開終端,在終端中輸入:ssh-add -K
,而後會讓你輸入生成SSH KEY的時候生成的密鑰,輸入一下就好了,以下圖所示gitlab
好了,你就會發現能正常拉代碼了。。ui
續: 發現電腦重啓後又須要執行一次ssh-add -K
,不知道爲何。。google
續,,終極解決辦法:spa
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>ssh-add-a</string>
<key>ProgramArguments</key>
<array>
<string>ssh-add</string>
<string>-A</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
複製代碼
~/Library/LaunchAgents