使用IDEA和GIT利用SSH拉取项目时报以下错误:
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好使。。
解决办法:
前置:已生成SSH KEY
第一步:
修改IDEA的配置,将 Version Control
> Git
> SSH executeable
调整为Native
,如下图所示
第二步:
打开终端,在终端中输入:ssh-add -K
,然后会让你输入生成SSH KEY的时候生成的密钥,输入一下就行了,如下图所示
好了,你就会发现能正常拉代码了。。
续:
发现电脑重启后又需要执行一次ssh-add -K
,不知道为什么。。
续,,终极解决办法:
- 新建一个.plist文件,比如我叫gitlab.self.plist
- 把下面的内容填进去
<?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