1.查看git是否配置全局的name/email
git config --list --global
2.如果没有name/email添加
git config --global user.name "New Name"
git config --global user.email "[email protected]"
3.ssh生成密钥
ssh-keygen -t rsa -b 4096 -C "[email protected]"
-
-t rsa
:指定密钥类型为 RSA(推荐使用 RSA,因为它更通用)。 -
-b 4096
:指定密钥长度为 4096 位(更高的密钥长度意味着更高的安全性)。 -
-C "[email protected]"
:添加一个注释,通常是你的电子邮件地址,用于标识密钥。
4.生成两个文件公钥与私钥
私钥:保存在 ~/.ssh/id_rsa 文件中。
公钥:保存在 ~/.ssh/id_rsa.pub 文件中。