ssh: Could not resolve hostname >配置hosts

前言: 搭建好gitlab后直接创建project后git地址为git@imacdj9Js:macRong/GitDemo.git,git clone时提示出错如下:
[cc lang=c]
sh: Could not resolve hostname imacdj9Js: nodename nor servname provided, or not known
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
[/cc]
这是你把imacdj9Js替换为你的域名地址就ok~ 但是这也不是办法(不是直接明文git地址是为了安全吗?后续了解下..),那就直接添加hosts吧!
解:
[cc lang=c]
sudo vim /etc/hosts
i
132.43.222.112 imacdj9Js
esc
:
wq!
[/cc]
把上面的ip地址和密文换成自己的就ok~ 重新git clone下 Checking connectivity… done.

<注>
如果没有ssh加入服务器上,
[cc lang=c]
ssh-keygen -t rsa -C “rong@zhece.com”
cat ~/.ssh/id_rsa.pub
//copy粘贴版
pbcopy < ~/.ssh/id_rsa.pub [/cc]在gitlab上添加sshkey ,然后重试上一步!

发表回复

电子邮件地址不会被公开。 必填项已用*标注