使用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