配置多公钥在多平台使用Git

步骤很详细,直接上教程

当我们想在不同远程仓库平台配置不同公钥时会发现不进行额外配置是不行的,只会使用默认的公钥,本篇文章便是为了解决这个问题

  1. 进入C:\Users\[你的用户名]\.ssh文件夹
    如果没有这个文件夹可以新建一下
  1. 在上述文件夹新建文件config
  1. 在该文件中填入以下模板内容

    此处举例了几个,不同平台需修改域以及我们设定的公钥文件名,文件名按自己的自行修改,建议使用眨眼睛的命名格式,

    生成公钥的命令行ssh-keygen -t rsa

bash 复制代码
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/github_id_rsa

# gitee
Host gitee.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitee_id_rsa

# codeup
Host codeup.aliyun.com
HostName codeup.aliyun.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/codeup_id_rsa
相关推荐
大志哥1233 小时前
idea+git插件+云备份实现项目新分支新建维护
git
恋喵大鲤鱼4 小时前
git merge
git·git merge
码客日记4 小时前
Spring Boot 配置文件敏感信息加密(Jasypt 企业级完整方案)
java·spring boot·git
_codemonster4 小时前
Codex 核心进阶玩法(技能/MCP/派生/分叉/Git/钩子/子智能体)
git
逻极5 小时前
Git 从入门到精通:版本控制协作实战指南
git·github·分支管理·版本控制
恋喵大鲤鱼5 小时前
git clean
git·git clean
Patrick_Wilson5 小时前
为省一次回归测试,该不该把多个改动堆进一条分支?
git·ci/cd·架构
恋喵大鲤鱼6 小时前
git blame
git·git blame
yeflx6 小时前
Git操作
git
恋喵大鲤鱼6 小时前
git pull
git·git pull