首页 git

clone github代码出现Operation timed out解决

发布于: 2024-04-21

1
2
3
4
5
6
7
➜  ~ git clone git@github.com:pkg6/go-requests.git
Cloning into 'go-requests'...
ssh: connect to host github.com port 22: Operation timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

首先要确定你的ssh证书书否正确,如果正确还是出现上面问题可以按照下面的流程进行解决

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# This should also timeout
$ ssh -T git@github.com
ssh: connect to host github.com port 22: Connection timed out

# but this might work
$ ssh -T -p 443 git@ssh.github.com
Hi xxxx! You've successfully authenticated, but GitHub does not provide shell access.

# Override SSH settings
$ cat > ~/.ssh/config << EOF
# Add section below to it
Host github.com
Hostname ssh.github.com
Port 443
EOF


$ ssh -T git@github.com
Hi xxxx! You've successfully authenticated, but GitHub does not provide shell access.

$ git clone git@github.com:pkg6/go-requests.git
Cloning into 'go-requests'...
remote: Enumerating objects: 461, done.
remote: Counting objects: 100% (259/259), done.
remote: Compressing objects: 100% (115/115), done.
remote: Total 461 (delta 167), reused 200 (delta 144), pack-reused 202
Receiving objects: 100% (461/461), 193.29 KiB | 257.00 KiB/s, done.
Resolving deltas: 100% (279/279), done.