当前位置:   article > 正文

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

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

检查、配置SSH

查看是否存在ssh
测试git是否成功连接github
在 github 上添加 SSH key 的步骤
如何生成SSH key及查看SSH key

异常

ssh -T git@github.com
如果出现:You’ve successfully authenticated,那么恭喜你,连接成功可以使用了。如果出现:ssh: connect to host github.com port 22: Connection timed out,很遗憾连接超时。
连接失败后,可以同样试试ssh -T git@ssh.github.comssh -T -p 443 git@github.comssh -T -p 443 git@ssh.github.com,检查是否有异常。

解决方法

配置新端口443

Host github.com							/* 服务器地址:github.com */
User YourEmail							/* 用户账号:github上的注册邮箱 */
Hostname ssh.github.com					/* 服务器地址为github地址*/
PreferredAuthentications publickey		/* 采用公匙 */
IdentityFile ~/.ssh/id_rsa				/* 公匙文件路径 */
Port 443								/* 端口 */
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  1. cd ~/.ssh
  2. vim config
  3. 编辑文件内容并保存退出
    Host github.com
    User git
    Hostname ssh.github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa
    Port 443
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    注册邮箱写成git即可。
  4. ssh -T git@github.com

gitlab中类似问题的解决

Host gitlab.com
Hostname altssh.gitlab.com
User git
Port 443
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

综合

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

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

Git问题:解决“ssh:connect to host github.com port 22: Connection timed out”
github默认端口22被占用,ssh: connect to host github.com port 22: Connection timed out
修改git path/etc/ssh/ssh_config

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/562889
推荐阅读
相关标签
  

闽ICP备14008679号