ssh: Could not resolve hostname ssh.github.com: Name or service not known fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.  

当笔者像平常一样使用着$git push origin master时,突然报错了,然后笔者又测试了一下 git clone 命令,仍然报错。然后记录一下解决方法

  • 打开/etc/resolv.conf
  • 添加两行nameserver
nameserver 8.8.8.8

nameserver 8.8.4.4

ps: 这里如果直接修改/etc/resolv.conf重启之后会失效。解决方法

但是作者使用下的Ubuntu16.10使用上面的方法是有问题的,可能是因为我自己做了一些不知道什么的事


最终的解决方案是:

  • 打开/etc/NetworkManager/NetworkManager.conf
  • 注释(加上#)或删除dns=dnsmasq这一行
  • sudo service NetworkManager restart

完美解决