git clone 遇到问题:fatal: unable to access

git clone 遇到问题:fatal: unable to access 'https://github.com/ros-planning/navigation.git/': Failed to connect to 127.0.0.1 port 40491: Connection refused

这是因为克隆地址需要用户名和密码登录才可以使用。

解决办法:

通过ssh方式链接远程仓库获取代码,操作如下:

第一步生成ssh-key并上传

该步骤需要windows安装git,具体安装方法很简单不在赘述。

git clone 遇到问题:fatal: unable to access

打开gitbash终端.png

默认情况下如果已经创建过ssh就不需要在创建,检查方法就是到/c/Documents and Settings/Administrator/.ssh目录下查看是否有一个公钥和私钥。

创建ssh key
$ ssh-****** -t rsa -C "your email address"  -- 填写github上面邮箱
连续按按三个Enterssh key创建成功  注意:生成id_rsa这是私钥文件。id_rsa.pub这是公钥文件。

git clone 遇到问题:fatal: unable to access

创建ssh-key成功.png

git clone 遇到问题:fatal: unable to access

获取公钥上传码云.png

第二步:在gitHub账户中添加key,讲将公钥复制到添加的可以中。

获取公钥上传码云.png

git clone 遇到问题:fatal: unable to access

第三部:获取git的ssh链接地址

获取到的地址格式如下
[email protected]:tiantangbaobao/test.git

git clone 遇到问题:fatal: unable to access

获取git的ssh链接地址

第四部:配置SourceTree clone源代码

 

git clone 遇到问题:fatal: unable to access

配置SourceTree的sshkey路径.png

git clone 遇到问题:fatal: unable to access

配置SourceTreessh秘钥.png

 

git clone 遇到问题:fatal: unable to access

权限不够.png


遇到上面的问题是因为改文件夹为核心文件必要系统对其做了保护,此时需要再我的电脑中运行获取所有权,需要使用Administrator用户登录电脑,之后会弹出一个执行命令的终端,释放文件夹的保护权限为所有人都可操作。

 

 

git clone 遇到问题:fatal: unable to access

QQ截图20170504222133.png


等待上一步命令执行完成后,就可以重新回到配置SourceTree的ssh秘钥界面,按下图选择秘钥。即可配置成功。

git clone 遇到问题:fatal: unable to access

QQ截图20170504222415.png

 

最终成功后就不会弹出ssh key 验证权限失败的问题


第四步 clone远程仓库

git clone 遇到问题:fatal: unable to access

clone远程仓库到本地.png



参考文章:
链接:https://www.jianshu.com/p/2a4a39e3704f