当遇到如标题所示问题,打开终端
MBP:baiyunshen_rn lianyu02$ git pull
git@gitlab.intebox.com: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
遇到这种问题怎么处理?很简单
如下:
ssh-keygen -t rsa -C "fangcaiwen",//fangcaiwen是你git操作的账号。
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/lianyu02/.ssh/id_rsa): //回车
Enter passphrase (empty for no passphrase): //回车
Enter same passphrase again: //回车
Your identification has been saved in /Users/lianyu02/.ssh/id_rsa.
Your public key has been saved in /Users/lianyu02/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:oXm37ngA1/jn+dHYsSTrePXNvT9hHEqdjl1ktdW8Z2w fangcaiwen
The key's randomart image is:
+---[RSA 2048]----+
| .=|
| B|
| .o .=o|
| .oo.. . =E|
| ooS.. ..*=+|
| ......o+@o|
| ..o o=oB|
| o. =. o=|
| .oo..o..=|
+----[SHA256]-----+
然后再执行,
cat /Users/lianyu02/.ssh/id_rsa.pub //这个路劲在你上面不断回车里可以找到
结果是:ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9+KpKzJKJjFkFABmSAPX74Rjn5qh3jQfbhbXppvIOTMU2fd/ribLQ+mP5Dj89IRAKGyQ/+vwyq0O6Y1e92Rst+Uyd9dgxk+CqK+fAsaHoVF9yCyJBA5eY6IiX5Vh5sbWHKsMfJUNt2rp9MjXrMJjkrxjCaa74iXeUvE9eN3ZRbxyehLP+EOv2nakxyvdao3moiWVHpJb1HdIoJQg9AGz5XqE6BLxegrpte0KJ+knnZtY1FE2Q7WvC/9pu9/IA7JWC8M85CcldR/iwRSDKn9bJesWIi0Og9tRAkRvSEQlr4lSL7fvlPDAV19tIRZ2itpD7uUESjFld05u0MMZjsMN7 fangcaiwen
如果你是gitlab出现这个问题,(github也一样)找到设置,点击SSH keys
如图所示:
按箭头所示.jpg
按图中箭头处粘贴上面的结果,点击增加Add key,然后回终端git pull,完美解决问题
链接:https://www.jianshu.com/p/c3089a7a7012