ssh: connect to host github.com port 22: Connection timed out

前端 未结 17 2383
陌清茗
陌清茗 2020-12-04 05:25

I am under a proxy and I am pushing in to git successfully for quite a while.
Now I am not able to push into git all of a sudden.
I have set the RSA key and the prox

相关标签:
17条回答
  • 2020-12-04 05:25

    Execute:

    nc -v -z <git-repository> <port>
    

    Your output should look like:

    "Connection to <git-repository> <port> port [tcp/*] succeeded!"
    

    If you get:

    connect to <git-repository> <port> (tcp) failed: Connection timed out
    

    You need to edit your ~/.ssh/config file. Add something like the following:

    Host example.com
    Port 1234
    
    0 讨论(0)
  • 2020-12-04 05:25

    When I accidentally switched to a guest wifi network I got this error. Had to switch back to my default wifi network.

    0 讨论(0)
  • 2020-12-04 05:27

    Basic URL Rewriting

    Git provides a way to rewrite URLs using git config. Simply issue the following command:

    git config --global url."https://".insteadOf git://
    

    Now, as if by magic, all git commands will perform a substitution of git:// to https://

    source: git:// protocol blocked by company, how can I get around that?

    0 讨论(0)
  • 2020-12-04 05:32

    The reason could be the firewall modification as you are under a network.(In which case they may deliberately block some ports)
    To double check if this is the reason ... do

    ssh -T git@github.com
    

    this should timeout. If that's the case use http protocol instead of ssh this way
    just change your url in the config file to http.
    Here is how :-

    git config --local -e
    

    change entry of

     url = git@github.com:username/repo.git
    

    to

    url = https://github.com/username/repo.git
    
    0 讨论(0)
  • 2020-12-04 05:35

    The main reason was the change from the proxy installed by the company recently, which has blocked other ssh connections other than those to the company domain.

    I was able to connect successfully by following these steps:

    1. Double checked that the issue is what I am assuming by ssh -T git@github.com

    It should end up in a timeout.

    1. Edited the local remote URL by

    ssh config --local -e

    and from

    url=git@github.com:asheeshjanghu/Journal.git

    to

    url=https://github.com/asheeshjanghu/Journal.git

    The important point is that in the url you have to change at 2 places.

    from git@ to https:// and from github:username to github/username

    In the end verify by doing a git fetch

    0 讨论(0)
  • 2020-12-04 05:36

    inside the .ssh folder Create "config" file

    Host github.com
    User git
    Hostname ssh.github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa
    Port 443
    
    Host gitlab.com
    Hostname altssh.gitlab.com
    User git
    Port 443
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa
    
    0 讨论(0)
提交回复
热议问题