Before this clear the old proxy git config --global --unset http.proxy git config --global --unset https.proxy
To access GitHub from a Ubuntu server in China, you may need to configure your system to bypass potential restrictions. Here are some steps you can follow:
-
Update your hosts file:
sudo nano /etc/hosts
Add these lines to the file:
140.82.113.3 github.com 140.82.114.20 gist.github.com 151.101.184.133 assets-cdn.github.com 151.101.184.133 raw.githubusercontent.com 151.101.184.133 gist.githubusercontent.com 151.101.184.133 cloud.githubusercontent.com 151.101.184.133 camo.githubusercontent.com 151.101.184.133 avatars0.githubusercontent.com 151.101.184.133 avatars1.githubusercontent.com 151.101.184.133 avatars2.githubusercontent.com 151.101.184.133 avatars3.githubusercontent.com 151.101.184.133 avatars4.githubusercontent.com 151.101.184.133 avatars5.githubusercontent.com 151.101.184.133 avatars6.githubusercontent.com 151.101.184.133 avatars7.githubusercontent.com 151.101.184.133 avatars8.githubusercontent.com
Save and exit the file.
-
Update the DNS settings:
sudo nano /etc/resolv.conf
Add these lines at the beginning of the file:
nameserver 8.8.8.8 nameserver 8.8.4.4
Save and exit the file.
-
Install and use a VPN: Consider using a VPN service to bypass restrictions. There are many options available, such as OpenVPN or WireGuard.
-
Use a proxy server: You can configure Git to use a proxy server:
git config --global http.proxy http://proxyserver:port git config --global https.proxy https://proxyserver:port
Replace
proxyserver
andport
with your proxy details. -
Use SSH instead of HTTPS: If possible, use SSH to connect to GitHub instead of HTTPS. This may help bypass some restrictions.
-
Try using a GitHub mirror: Some services provide mirrors of GitHub repositories, which might be more accessible from China.
Remember that internet regulations in China can change, so these methods may not always work. Always ensure you're complying with local laws and regulations when using these methods.