解决IDEA用SSH方式拉取Github项目:Could not read from remote repository

mac2024-03-31  27

背景:

今天在公司的电脑上使用 IDEA 用SSH方式拉取Github上的项目报错:

Could not read from remote repository

上网一顿查,将SSH executable 改成Native 没有用

最后分析问题应该是 ssh key 配置有问题,于是重新配置了一番,问题解决。

 

详细步骤:

1. 找到C盘里的 .ssh 目录给删掉(如果有的话)

2. 使用 Git Bash 重新生成 SSH key

$ cd ~ #保证当前路径在”~”下 $ ssh-keygen -t rsa -C "xxxxxx@yy.com" #建议填写自己真实有效的邮箱地址 Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/xxxx_000/.ssh/id_rsa): #不填直接回车 Enter passphrase (empty for no passphrase): #输入密码(可以为空) Enter same passphrase again: #再次确认密码(可以为空) Your identification has been saved in /c/Users/xxxx_000/.ssh/id_rsa. #生成的密钥 Your public key has been saved in /c/Users/xxxx_000/.ssh/id_rsa.pub. #生成的公钥 The key fingerprint is: e3:51:33:xx:xx:xx:xx:xxx:61:28:83:e2:81 xxxxxx@yy.com

3. 将重新生成的.ssh文件夹下id_rsa.pub的公钥内容添加到 Github 里面,具体步骤不再赘述。

4. 使用 Git Bash 配置一下自己的账户

$ git config --global user.name “your_username” #设置用户名 $ git config --global user.email “your_registered_github_Email” #设置邮箱地址(建议用注册giuhub的邮箱)

5. 测试

$ ssh -T git@github.com The authenticity of host 'github.com (192.30.252.129)' can't be established. RSA key fingerprint is 16:27:xx:xx:xx:xx:xx:4d:eb:df:a6:48. Are you sure you want to continue connecting (yes/no)? yes #确认你是否继续联系,输入yes Warning: Permanently added 'github.com,192.30.252.129' (RSA) to the list of known hosts. Hi xxx! You have successfully authenticated, but GitHub does not provide shell access. #出现这句话,说明设置成功。

6. 再使用IDEA拉取项目就不报错了

最新回复(0)