一、环境
为 Gitee、GitHub 配置ssh
二、配置两个仓库公钥
A 生成 Gitee SSH 公钥
-
生成 SSH 公钥
ssh-keygen -t ed25519 -f gitee -C "Gitee SSH Key"-t: key 类型
-f: 自定义命名
-C: 注释
- 中间通过三次回车键确定
-
查看生成的 SSH 公钥和私钥
ls ~/.ssh/私钥文件:
gitee公钥文件
gitee.pub -
读取公钥文件
~/.ssh/gitee.pub并填写到 Gitee 个人设置」->「安全设置」->「SSH 公钥」->「添加公钥」cat ~/.ssh/gitee.pub
B 按照同样的方式生成 GitHub 的 ssh 公钥
在生成公钥时 -f 后面自定义一个名字,不要和 gitee 重复
ssh-keygen -t ed25519 -f github -C "Github SSH Key"
三、配置 ssh config
-
新建 config
在
~/.ssh/下新建文件config并填写如下内容:vim ~/.ssh/config # 填写如下内容 # gitee Host gitee.com HostName gitee.com PreferredAuthentications publickey IdentityFile ~/.ssh/gitee # github Host github.com HostName github.com PreferredAuthentications publickey IdentityFile ~/.ssh/github
配置Gitee与GitHubSSH公钥教程
本文详细介绍了如何为Gitee和GitHub配置SSH公钥,包括生成不同平台的SSH密钥,添加公钥到个人设置,以及创建sshconfig文件以区分不同的服务。通过这些步骤,用户可以安全地进行版本控制操作。
5044

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



