一、问题
换电脑了,克隆代码遇到报错:
git clone git@codeup.aliyun.com:qwertyuiopasdfghjkl/projectName.git
Cloning into 'projectName'...
找不到代码库,请确认是否有权限且代码库路径正确
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
找到本地公钥,复制到添加 SSH 公钥处,遇到报错:
该密钥已被添加为用户密钥或部署密钥,添加失败
官方提出的解决办法:添加 SSH Keys 报已存在怎么办?
按照官方的提示,大概率是原因1,只能重新生成了
但是现在本地这个 SSH Key 在其他地方有使用(Gitee/Github/…),想要保留,再生成一个。
二、解决
按照以下两篇官方说明:
- 如何在同一台电脑上配置多个SSH Key?
- 配置 SSH 密钥
决定尝试 ED25519 算法生成的密钥(同一算法需要指定不同路径,使用不同算法就免了)
ssh-keygen -t ed25519 -C "<注释内容>"
按照默认路径生成后,配置config文件(~/.ssh/config)
# Codeup (2023.05.18 add)
HostName codeup.aliyun.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_ed25519
当本地存在多个密钥,如果不设置认证规则,本机将随机选择一个密钥用于认证,可能造成认证失败。
接下来复制公钥粘贴到指定位置
# Windows
cat ~/.ssh/id_ed25519.pub | clip
保存后就可以使用啦
三、拓展学习
1.ssh命令
- 远程登录(查看当前使用的密钥对应的账号)
ssh -t git@codeup.aliyun.com
正常显示:
Welcome to Codeup, userName!
Connection to codeup.aliyun.com closed.
SSH(远程登录)
2.Ed25519:一个高速度高安全的签名方法
- Ed25519:一个高速度高安全的签名方法
- 官方介绍:Introduction
- 它的签名长度为64个字节,公钥长度是32个字节
签名一共经过三个环节文章来源:https://www.toymoban.com/news/detail-496482.html
- 生成公钥、私钥
- 使用私钥签名
- 使用公钥验签
over文章来源地址https://www.toymoban.com/news/detail-496482.html
到了这里,关于【已解决】git clone 报错:Could not read from remote repository. Please make sure you have the correct acce的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!