经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 程序设计 » 编程经验 » 查看文章
git错误--ssh: Could not resolve hostname ssh.github.com: Name or service not known--解决方式
来源:cnblogs  作者:子钦加油  时间:2018/9/25 19:55:03  对本文有异议

错误如下: 
git push origin 
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. 
make: * [deploy] 错误 128

解决方式1: 
step1. ping github.com 
获取到github.com的ip为192.30.252.128 
step2. 在/etc/hosts中添加一行如下: 
192.30.252.128 github.com

解决方式2: 
以root权限执行如下python代码

#!/usr/bin/python
#coding=utf8

import socket

host = 'github.com'

try:
    with open('/etc/hosts', 'a+') as fp: 
        ip = socket.gethostbyname(host)
        fp.write(' '.join([ip, host, '\n']))
except BaseException as e:
    print(e)
else:
    print('sucess')
 友情链接:直通硅谷  点职佳  北美留学生论坛