ssh: Could not resolve hostname github.com: Name or service not known; fatal: The remote end hung up unexpectedly

后端 未结 7 1618
予麋鹿
予麋鹿 2020-12-12 20:10

The process of setting up a GitHub account works just fine but it doesn\'t work when I try pushing my repository to GitHub. The error message it shows is as follows:

相关标签:
7条回答
  • 2020-12-12 20:39

    Github is currently (on 22nd of feb 2012, again on 5th of sept 2016) having some problems with pushing/pulling over ssh. I'm experiencing the same problems.

    Pulling over https is working thought.

    You can try pushing over https by following this guide: https://help.github.com/articles/using-ssh-over-the-https-port/

    This would only help if https is not affected. you can try if https://status.github.com/ shows signs of things slowing down. Graphs where the mean response time goes up means there are issues (or possibly a DDOS) at github, and not at your end.

    If github is currently being DDOS'ed they may choose to enable DDOS protection from a 3rd party. This would mean they change their dns records and/or servers if these are part of the DDOS.

    Flushing your dns, changing your dns server or restarting your network (which will possibly flush your dns cache) as stated in the other answer might help in fixing the issue for you if github is mitigating a DDOS.

    Or if you have problems with your ssh setup you can find the ssh faq here: http://help.github.com/ssh-issues/

    Other ways to flush your dns, in windows in your terminal

    ipconfig /flushdns
    

    on macos

    dscacheutil -flushcache
    

    on linux

    service nscd restart
    

    or simply rebooting ;)

    0 讨论(0)
  • 2020-12-12 20:40

    In my case I had misspelled something when manually adding the remote origin with git remote add origin ....

    It's worth checking your remote is correct with git remote -v

    0 讨论(0)
  • 2020-12-12 20:54

    Sometimes restarting your machine is also a good idea. When I faced the same issue after restarting the system, it told me that your private key is locked and github cant access that.. so enter your password to do that.. I entered the password and then the issue was resolved.

    0 讨论(0)
  • 2020-12-12 20:58

    Recently, I have seen this problem too. Below, you have my solution:

    1. ping github.com, if ping failed. it is DNS error.
    2. sudo vim /etc/resolv.conf, the add: nameserver 8.8.8.8 nameserver 8.8.4.4

    Or it can be a genuine network issue. Restart your network-manager using sudo service network-manager restart or fix it up

    0 讨论(0)
  • 2020-12-12 21:02

    I have just received this error after switching from HTTPS to SSH (for my origin remote). To fix, I simply ran the following command (for each repo):

    ssh -T git@github.com

    Upon receiving a successful response, I could fetch/push to the repo with ssh.

    I took that command from Git's Testing your SSH connection guide, which is part of the greater Connecting to GitHub with with SSH guide.

    0 讨论(0)
  • 2020-12-12 21:03

    On centos 7

    1. check ip address using command ifconfig. you will get information like this

      ens33: flags=****<UP,BROADCAST,RUNNING,MULTICAST>  mtu ****
      
      inet ***.***.***.***  netmask ***.***.***.0  broadcast ***.***.***.***
      
    2. add inet ip address and hostname in file /etc/hosts

      a. open file vi /etc/hosts

      b. add ip and host like ip_address hostname hostname

    3. reboot

    It will attach ip and host.

    0 讨论(0)
提交回复
热议问题