当我在国内 Linux 机器上安装好 Git 环境后,将 github 代码克隆到 Linux 服务器出现了如下问题
1 2 3 4 5 6 7
[root@ydyno ~]# git clone git@github.com:elunez/**.git 正克隆到 '**'... 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.
解决方法
进入 ~/.ssh 查看是否缺少 config 配置文件,如果缺少该配置文件那么使用如下命令创建
1 2 3 4 5 6 7 8 9
# 创建并写入文件数据 vi ~/.ssh/config # 写入如下数据,User 填入注册时的邮箱 Host github.com User xxxxx@xx.com Hostname ssh.github.com PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa Port 443