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

前端 未结 17 2402
陌清茗
陌清茗 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:38

    I faced the same problem and couldn't find a working solution. I faced this problem while setting up a local server and the git couldn't connect through my proxy network but my workstation could. This was the output when I ran the command ssh -vT git@github.com

    ubuntu@server:~$ ssh -vT git@github.com
    OpenSSH_7.2p2 Ubuntu-4ubuntu2.8, OpenSSL 1.0.2g  1 Mar 2016
    debug1: Reading configuration data /home/ubuntu/.ssh/config
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: /etc/ssh/ssh_config line 19: Applying options for *
    debug1: Connecting to github.com [13.234.176.102] port 22.
    

    So I tried using an SSH connection made over the HTTPS port by editing the config file ~/.ssh/config but to no avail.

    Host github.com
     Hostname ssh.github.com
     Port 443
    

    Finally, I found this article which solved and exposed the real problem.

    # github.com
    Host github.com
        Hostname ssh.github.com
        ProxyCommand nc -X connect -x : %h %p
        Port 443
        ServerAliveInterval 20
        User git
    

    This is my config file and now git works perfectly well through ssh!

提交回复
热议问题