ubuntu解决git clone时fatal Could not read from remote repository问题

问题现象:ubuntu下clone 代码库出现如下问题:

ubuntu解决git clone时fatal Could not read from remote repository问题_第1张图片

Cloning into 'OrbbecSDKStressTestTool'...

The authenticity of host '120.78.87.224 (120.78.87.224)' can't be established.

ECDSA key fingerprint is SHA256:uZepgq8XJ9zB/XIHCtZvyhlMRWuldWuWv2kuo3OobbQ.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '120.78.87.224' (ECDSA) to the list of known hosts.

[email protected]'s password:

Permission denied, please try again.

[email protected]'s password:

Connection to 120.78.87.224 closed by remote host.

fatal: Could not read from remote repository.

 

Please make sure you have the correct access rights

and the repository exists.

 

问题原因:

在git 上没有创建SSH key。

 

解决办法:

第一步,生成key,需要输入的地方点击回车即可。

ubuntu解决git clone时fatal Could not read from remote repository问题_第2张图片

guanlin@ubuntu:~/.ssh$ ssh-keygen -t rsa -C "[email protected]"

Generating public/private rsa key pair.

Enter file in which to save the key (/home/guanlin/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /home/guanlin/.ssh/id_rsa.

Your public key has been saved in /home/guanlin/.ssh/id_rsa.pub.

The key fingerprint is:

SHA256:sr5HL4ndE1v15yTE4p4QdSW7OS+0LiP8gluLz3HaIWk [email protected]

The key's randomart image is:

+---[RSA 2048]----+

|              ...|

|            . .o |

|           . o.  |

|          . . +o |

|      . S  o +=. |

|       o. o.o..++|

|      .+ *E*o.o+o|

|     .. *=OB=o ..|

|      ooo+==oo.  |

+----[SHA256]-----+

 

第二步,参看下SSH 是否已经生成。查看时,需进入~/.ssh目录,如果目录下有id_rsa 及 id_rsa.pub这两个文件说明SSH key已经生成了。

guanlin@ubuntu:~/.ssh$ ls

id_rsa  id_rsa.pub  known_hosts

 

第三步,添加私钥:

guanlin@ubuntu:~/.ssh$ ssh-add id_rsa

Identity added: id_rsa (id_rsa)

 

第四步,在gitlab 网页上添加公钥。即将id_rsa.pub文件中的内容拷贝出来添加到网页上。

ubuntu解决git clone时fatal Could not read from remote repository问题_第3张图片

guanlin@ubuntu:~/.ssh$ cat id_rsa.pub

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC77d3EVPLQB2/pjKBonSppmUr4WoJmpoSGbZrblMIoAfPaffDydWf7/ODbyieZASNBI4LT+mBwLbuxQYDx49VkeuMMPYnXR+0jO9OjnvCCCSWZTwi7EIRTGdfCRGDyyfrovqasIkyBEUURv1x7uE95le3S0OBW0h+ubDC3Dk+qBNXkhbD6ce1VzwPDTAuEzFjA86vIq1vix8os7IUsi6fjnmDUQeA3a7f3VwLtA6+z8s7Z1aY0c9lrGJh/Ib09G81/KpBjb9auvcb4oqWEj4PD2wWIEYj5OO/oE3rl5x36uA2gb8g3+ACUhWBGrFPPNI8+B2N/AGgK38zAhxVx9iLd [email protected]

 

将上面内容拷贝出来后,粘贴到网页中Key的位置,点击Add key 即可添加成功。

ubuntu解决git clone时fatal Could not read from remote repository问题_第4张图片

 

这时重新clone就可以成功了。

ubuntu解决git clone时fatal Could not read from remote repository问题_第5张图片

 

参考博客:

https://www.cnblogs.com/wmr95/p/7852832.html

你可能感兴趣的:(Git)