问题
在使用git pull 时出现以下错误: 以及以下错误: 将原项目删除后,尝试使用项目的SSH连接下载仓库,出现以下错误:
(base) william@Tower:~/workspace/github$ git clone git@github.com:xxxxxx/xxx.git
正克隆到 'tx'...
ssh: connect to host github.com port 22: Connection timed out
fatal: 无法读取远程仓库。
请确认您有正确的访问权限并且仓库存在。
解决方案
首先,确保项目所在账号将你的个人账号添加至该项目访问权限。 然后,在本地生成SSH密钥和公钥(可参考相关文章),将公钥添加至Github个人账号中的头像 → Settings → 左侧 SSH and GPG keys。 完成后进行连接测试,发现以下错误:
(base) william@Tower:~/workspace/github$ ssh -T git@github.com
ssh: connect to host github.com port 22: Connection timed out
在本地.ssh目录下(和密钥公钥同一个目录)下创建一个新的文件config,内容如下:
Host github.com
User xxxxxx@xxx.com
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443
再次测试,成功(记得中途输入yes):
(base) william@Tower:~/workspace/github$ ssh -T git@github.com
The authenticity of host '[ssh.github.com]:443 ([20.205.243.160]:443)' can't be established.
ECDSA key fingerprint is SHA256:p2QAMXNIC1TJYWeIOttrVc98/R1BUFWu3/LiyKgUfQM.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[ssh.github.com]:443,[20.205.243.160]:443' (ECDSA) to the list of known hosts.
Hi xxxxxx! You've successfully authenticated, but GitHub does not provide shell access.
继续克隆项目仓库,成功:
(base) william@Tower:~/workspace/github$ git clone git@github.com:xxxxxx/xxx.git
正克隆到 'tx'...
remote: Enumerating objects: 336, done.
remote: Counting objects: 100% (336/336), done.
remote: Compressing objects: 100% (211/211), done.
remote: Total 336 (delta 140), reused 276 (delta 91), pack-reused 0
接收对象中: 100% (336/336), 29.79 MiB | 1.53 MiB/s, 完成.
处理 delta 中: 100% (140/140), 完成.
|