同时为github和gitee配置公钥
1.下载git
https://git-scm.com/download/win
2.配置公钥
参考 https://help.gitee.com/base/account/SSH公钥设置
通过命令 ssh-keygen
生成 SSH Key:
ssh-keygen -t ed25519 -C "[email protected]"
输入秘钥文件名,其他回车
id_rsa_github
id_rsa_gitee
3.将公钥添加到对应的github和gitee服务器上
4.将私钥添加到本地中
如有 该报错 Could not open a connection to your authentication agent.
执行 ssh-agent bash
ssh-add id_rsa_github
ssh-add id_rsa_gitee
ssh-add -l
256 SHA256 邮箱(ED25519)
5.添加config配置,实现根据仓库的 remote 链接地址自动选择合适的私钥。
$ cat config
# github
Host github.com
HostName github.com
User iniwym
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_github
# gitee
Host gitee.com
HostName gitee.com
User iniwym
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_gitee
6.验证
ssh -T [email protected]
ssh -T [email protected]
# 查看具体日志
ssh -v -T [email protected]
git常用全局配置
# 设置全局默认分支为main
git config --global init.defaultbranch main
# 设置用户名
git config --global user.name "iniwym"
# 设置邮箱
git config --global user.email "[email protected]"
#查看全局配置
git config --global --list
init.defaultbranch=main
user.name=iniwym
[email protected]
end
标签:git,rsa,gitee,github,公钥,ssh,com From: https://www.cnblogs.com/iniwym/p/17866129.html