当前位置:   article > 正文

【git】 ssh拉代码,为何出现timeout链接超时?_git ssl connection timeout

git ssl connection timeout

原因:
1.公司屏蔽了端口22的访问,检测一下端口22是否能够链接?
2.本机防火墙的缘故而不能使用端口22?

windows下检测端口是否能够访问

PowerShell 版本是5及其以后,直接使用命令Get-NetTCPConnection参看与端口相关的信息


PS C:\> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.14393.693
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.693
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1


PS C:\> Get-NetTCPConnection -LocalPort 80 | Format-Table -Property LocalAddress, LocalPort, State, OwningProcess

LocalAddress LocalPort  State OwningProcess
------------ ---------  ----- -------------
::                  80 Listen             4

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21

使用命令use Test-NetConnection测试远程主机的端口

PS C:\> Test-NetConnection -ComputerName 10.216.25.35 -Port 443 -InformationLevel Detailed

ComputerName            : 10.216.25.35
RemoteAddress           : 10.216.25.35
RemotePort              : 443
NameResolutionResults   : 10.216.25.35
MatchingIPsecRules      :
NetworkIsolationContext : Private Network
InterfaceAlias          : Ethernet
SourceAddress           : 10.61.39.173
NetRoute (NextHop)      : 10.61.36.1
TcpTestSucceeded        : True

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

如果是公司屏蔽端口访问,则使用http进行访问,对于git的url进行覆写

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

  • 1
  • 2
  • 3

~/.gitconfig 文件中可以看到:

[url "https://"]
   insteadOf = git://
  • 1
  • 2

因为防火墙的缘故22不能被使用,那换443

先测试443能不能用?

 $ ssh -T -p 443 git@ssh.github.com
> Hi username! You've successfully authenticated, but GitHub does not
> provide shell access.
  • 1
  • 2
  • 3

~/.ssh/config文件下设置:

Host github.com
  Hostname ssh.github.com
  Port 443
  • 1
  • 2
  • 3

测试是否设置成功

$ ssh -T git@github.com
> Hi username! You've successfully authenticated, but GitHub does not
> provide shell access.
  • 1
  • 2
  • 3
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/514064
推荐阅读
相关标签
  

闽ICP备14008679号