简体   繁体   English

将github的IP地址设置为原始URL

[英]Setting the IP address of github as the origin url

I have a server that has DNS problems and cannot find "Github.com". 我的服务器存在DNS问题,找不到“ Github.com”。 I have to use Github's IP address instead. 我必须改用Github的IP地址。 But when I try to use the IP address like this: 但是,当我尝试像这样使用IP地址时:

git remote set-url origin http://192.30.253.113/foo/bar.git

when I try to push to origin this happens: 当我尝试推动起源时,会发生以下情况:

git push origin master

fatal: unable to access ' https://192.30.253.113/foo/bar.git/ ': SSL: certificate subject name (github.com) does not match target host name '192.30.253.113' 致命:无法访问' https://192.30.253.113/foo/bar.git/':SSL :证书使用者名称(github.com)与目标主机名'192.30.253.113'不匹配

Git pull does not work, because Git verifies the SSL certificate and checks whether the hostname matches the name in the certificate. Git pull不起作用,因为Git会验证SSL证书并检查主机名是否与证书中的名称匹配。 In your case the IP is not included in the certificate and, thus, you are getting this error. 在您的情况下,证书中不包含IP,因此,您将收到此错误。

An option could be to disable SSL (as described in https://stackoverflow.com/a/16869961/3906760 ), however, that would allow attackers to MitM your connection. 一个选项可能是禁用SSL(如https://stackoverflow.com/a/16869961/3906760中所述 ),但是,这将允许攻击者攻击MitM您的连接。

Instead of disabling SSL verification, why don't you add github.com to /etc/hosts (cf. https://ubuntuforums.org/showthread.php?t=3407 ), then SSL certificate validation would still work. 除了禁用SSL验证之外,为什么不将github.com添加到/ etc / hosts中(请参阅https://ubuntuforums.org/showthread.php?t=3407 ),那么SSL证书验证仍然可以进行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM