1.检查有无密钥,无输出则代表需要
ls -al ~/.ssh
2.生成新的 SSH 密钥
ssh-keygen -t ed25519 -C "your_email@example.com"
当提示你 “Enter a file in which to save the key”(输入保存密钥的文件)时,直接按 Enter 键使用默认位置,输入完成后按 Enter 即可。如果你不想设置密码,直接按 Enter。
3.将 SSH 密钥添加到 ssh-agent(后台管理程序)
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
4.将 SSH 公钥添加到你的 GitHub 账户
找到公钥文件(~/.ssh/id_ed25519.pub),用文本编辑器(如记事本、VSCode)打开,全选并复制全部内容。复制的内容应该是一长串以 ssh-ed25519 开头,以你的邮箱结尾的文本。

5.测试 SSH 连接
ssh -T git@github.com
输入 yes 并按 Enter。
6.示例
git clone git@github.com:autowarefoundation/autoware.git -b humble
7.https更改成SSH链接:
sed -i 's|https://github.com/\([^/]*\)/\([^/]*\)|git@github.com:\1/\2.git|g' autoware.repos

1471

被折叠的 条评论
为什么被折叠?



