Github项目无法通过 ssh 连接,以前正常使用的,现在无法 push pull

Github项目无法通过 ssh 连接,以前正常使用的,现在无法 push pull

一、问题描述

2024-01-18
这两天遇到一个问题,就是以前正常使用的项目,现在无法 push 或 pull 了。
我所有的项目都是以 git@github.com:KyleBing/xxxx.git 的方式使用的,不想改成 https://

错误提示是这样的:

ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.

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

二、解决

我将以前那种方式

git clone git@github.com:KyleBing/iphone.git iphone-vue

改成

git clone ssh://git@ssh.github.com:443/KyleBing/iphone.git iphone-vue

是可行的。

但其实有更方便的方法。

只需要在 ~/.ssh/config 中添加以下配置,以前的项目就都能正常使用了。

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

官方说明文档:
https://docs.github.com/en/authentication/troubleshooting-ssh/using-ssh-over-the-https-port

# 以这种方式使用是可以的,但不方便。
Kyle@Kyles-mbp tools % git clone ssh://git@ssh.github.com:443/KyleBing/iphone.git iphone-vue
Cloning into 'iphone-vue'...
remote: Enumerating objects: 1483, done.
remote: Counting objects: 100% (224/224), done.
remote: Compressing objects: 100% (152/152), done.
remote: Total 1483 (delta 148), reused 141 (delta 72), pack-reused 1259
Receiving objects: 100% (1483/1483), 6.00 MiB | 2.79 MiB/s, done.
Resolving deltas: 100% (936/936), done.

# 其实只需要添加关于 github 的 ssh 配置
Kyle@Kyles-mbp tools % vi ~/.ssh/config

# 就能测试验证成功
Kyle@Kyles-mbp tools % ssh -T git@github.com
Hi KyleBing! You've successfully authenticated, but GitHub does not provide shell access.

# 之前的项目也能正常使用了。

相关推荐

  1. 配置SSHGitHub无法使用

    2024-01-19 08:30:03       40 阅读
  2. github 通过ssh进行连接另一种方式

    2024-01-19 08:30:03       53 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-19 08:30:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-19 08:30:03       100 阅读
  3. 在Django里面运行非项目文件

    2024-01-19 08:30:03       82 阅读
  4. Python语言-面向对象

    2024-01-19 08:30:03       91 阅读

热门阅读

  1. SpringBoot+Redisson分布式锁

    2024-01-19 08:30:03       45 阅读
  2. RabbitMQ扩展

    2024-01-19 08:30:03       38 阅读
  3. GoLang刷题之leetcode

    2024-01-19 08:30:03       48 阅读
  4. 把前端传来的数据导入到excel文件

    2024-01-19 08:30:03       56 阅读
  5. 软件工程客观题知识点简易汇总

    2024-01-19 08:30:03       55 阅读
  6. MongoDB面试系列-03

    2024-01-19 08:30:03       52 阅读
  7. C语言整型常量的存储形式是怎样的?

    2024-01-19 08:30:03       51 阅读
  8. Js面试之作用域与闭包

    2024-01-19 08:30:03       53 阅读
  9. STL-string

    2024-01-19 08:30:03       54 阅读
  10. c++学习之特殊类设计与类型转换

    2024-01-19 08:30:03       57 阅读
  11. Qt中ListWidget控件总结

    2024-01-19 08:30:03       57 阅读