这两天学习git的时候,在本地创建了一个库,同时自己在GitHub上面也创建了一个库,照着廖老师的教程一步一步走到了push的环节突然出现了这样的错误:

[zhangxiyu@localhost learngit] $ git push -u origin master 
Permission denied (publickey). 
fatal: The remote end hung up unexpectedly

去百度,CSDN,GitHub等等各种地方去查只得到一个答案,说是pubickey没有绑定到远程GitHub上,但这个步骤之前分明已经都做过了,没办法只好把GitHub上的公钥删掉,同时在本地rm -r ~/.ssh把.ssh文件夹全删掉重新生成ssh-keygen,重新把.ssh/id_rsa.pub绑定到GitHub。结果呢,还尼玛不行。还是提示上面的错误!woc!!!见了鬼了。然后就陷入了死循环,到处找解决方法,但结果是清一色的“没有绑定公钥”。

好在天无绝人之路,今天无意中看到了git push上传代码到gitlab上,报错401/403(或需要输入用户名和密码)这个帖子,突然想到了,昨天在push之前好像也遇到过这个问题:

[zhangxiyu@localhost learngit]$ git push -u github 
error: The requested URL returned error: 403 Forbidden while accessing 
https://github.com/zxy9527/zxy.git/info/refs

fatal: HTTP request failed

然后在网上查找了一下问题不知怎么的就果断vi .git/config,然后把

[remote “github”] 
url = https://github.com/zxy9527/zxy.git 
fetch = +refs/heads/:refs/remotes/github/

改成了

[remote “github”] 
url = ssh://github.com/zxy9527/zxy.git 
fetch = +refs/heads/:refs/remotes/github/

喜大普奔,403的问题没有了,但随之而来的就是无限的Permission denied (publickey)。。。就是上面说的问题。

  • 解决办法

在代码的.git/config文件内[remote “origin”]的url的gitlab域名前添加gitlab注册时的“用户名:密码@”

例如我的GitHub用户名为blx9527,密码为blx123456(当然不是真的密码~),所以.git/config文件内就应该改为:

[remote “github”] 
url = https://blx9527:blx123456@github.com/zxy9527/zxy.git 
fetch = +refs/heads/:refs/remotes/github/

改完之后,确保你的公钥已经绑定到GitHub(这个网上有很详细的教程)之后,就可以愉快的push啦!!

Permission denied (publickey). fatal: The remote end hung up unexpectedly 解决办法的更多相关文章

  1. fatal: The remote end hung up unexpectedly解决办法

    $ git config --global http.postBuffer 2428000 git config http.postBuffer 524288000 配置完成后 git pull一下, ...

  2. ssh: Could not resolve hostname git.*****-inc.com : Temporary failure in name resolution fatal: The remote end hung up unexpectedly

    问题出现的情景:使用git pull拉取开发的代码到测试服务器,报错: ssh: Could not resolve hostname git.****-inc.com : Temporary fai ...

  3. github Permission denied (publickey). fatal: Could not read from remote repository.

    github Permission denied (publickey).fatal: Could not read from remote repository. ----------------- ...

  4. git克隆出错 github clone Permission denied (publickey) fatal Could not read from remote repo

    原文网址:http://blog.csdn.net/feeling450/article/details/53067563 github clone "Permission denied ( ...

  5. github下载报错:Permission denied (publickey). fatal: Could not read from remote repository.

    Permission denied (publickey). fatal: Could not read from remote repository. 博主在github上下载tiny face的的 ...

  6. 【git基础】Permission denied (publickey). fatal: Could not read from remote repository

    运行以下git命令的时候出现错误 git push -u origin master error The authenticity of host 'github.com (13.250.177.22 ...

  7. git提交报异常,fatal: The remote end hung up unexpectedly

    转自:http://liucanwen.iteye.com/blog/2021601 早上提交代码到 oschina代码库时,报了这个错误: fatal: The remote end hung up ...

  8. Git 提交大文件提示 fatal: The remote end hung up unexpectedly

    使用gitlab搭建的git server,如果直接使用http的方式去提交的话,提交小文件不会有问题,但是提交大文件时,会出错: fatal: The remote end hung up unex ...

  9. fatal: The remote end hung up unexpectedly

    git push 的时候出错,提示: fatal: The remote end hung up unexpectedly 遇见几次了,原因是因为文件太大,把限制放宽就好了.命令: git confi ...

随机推荐

  1. Eclipse 如何导入web项目

      Eclipse 如何导入web项目 CreateTime--2018年3月8日09:07:16 Author:Marydon 方法一:推荐使用 1.将web项目手动拷贝到Eclipse的工作空间下 ...

  2. 身份证查询API

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #http://apistore.baidu.com/apiworks/servicedetail/113.h ...

  3. 科普:TLS、SSL、HTTPS以及证书(转)

    最近在研究基于ssl的传输加密,涉及到了key和证书相关的话题,走了不少弯路,现在总结一下做个备忘 不少人可能听过其中的超过3个名词,但它们究竟有什么关联呢? TLS是 传输层安全协议(Transpo ...

  4. Java下Elasticsearh应用指南

    简介 本文针对在Java下操作elasticsearch给出应用示例,主要涉及创建连接,构建索引以及检索数据3个部分. 环境 1)elasticsearch2.4.4, 2)jdk1.8. 客户端连接 ...

  5. linux脚本加密shc

    linxu的shell脚本看下源码,都能明白含义.加密也是很关键的 01.安装shc加密 http://www.datsi.fi.upm.es/~frosal/sources/   ###下载源码 百 ...

  6. Coding.net+Myeclipse 2014 Git配置

    安装Git,然后 $ssh-keygen -t rsa -b 4096 -C "your_email@example.com" # Creates a new ssh key, u ...

  7. HDUOJ------Lovekey

    Lovekey Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Sub ...

  8. android开发学习之ViewPager滑动事件讲解

    android ViewPager滑动事件讲解 今天在做项目的时候,由于要处理viewPager页面滑动的事件,所以对其进行了一个小小的研究: 首先ViewPager在处理滑动事件的时候要用到OnPa ...

  9. RabbitMQ与.net core(二)Producer与Exchange

    Producer:消息的生产者,也就是创建消息的对象 Exchange:消息的接受者,也就是用来接收消息的对象,Exchange接收到消息后将消息按照规则发送到与他绑定的Queue中.下面我们来定义一 ...

  10. python学习笔记011——闭包

    1 定义 定义:在计算机科学中,闭包是词法闭包的简称,是引用了自由变量的函数 简单地说:闭包就是能够读取其他函数内部变量的函数,闭包是将函数内部和函数外部连接起来的桥梁.——来源百度百科 2 描述 形 ...