Skip to content

Instantly share code, notes, and snippets.

@llccing
Last active October 30, 2024 14:26
Show Gist options
  • Save llccing/1ac6d30959cb91d8762cac19e263154d to your computer and use it in GitHub Desktop.
Save llccing/1ac6d30959cb91d8762cac19e263154d to your computer and use it in GitHub Desktop.

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:

  1. 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.

  2. 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.

  3. Install and use a VPN: Consider using a VPN service to bypass restrictions. There are many options available, such as OpenVPN or WireGuard.

  4. 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 and port with your proxy details.

  5. Use SSH instead of HTTPS: If possible, use SSH to connect to GitHub instead of HTTPS. This may help bypass some restrictions.

  6. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment