配置多公钥在多平台使用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
相关推荐
网络毒刘1 小时前
开源 Aider 工作流实战:Git 提交驱动的 AI 结对,与 Cursor 何时互补
git·ai编程·cursor·aider
HRTOS3 小时前
HRTOS 4.0 将长期维护:为什么版本号不再频繁变化
经验分享·git·单片机·51单片机
驭渊的小故事20 小时前
linux 基础命令 + git 仓库创建和配置命令
linux·git
行者-全栈开发1 天前
华为云码道 CodeArts 实测:让 AI 用 Rust 写一个 Git 仓库健康度体检台「仓衡」
git·rust·tauri·桌面应用·ai 编程·华为云码道·codearts 代码智能体
挖掘狂人3 天前
Git 从 0 到 1:用一个小项目走完 add / commit / reset / merge / rebase / push
git·后端·github
codigger3 天前
Git 三区域模型:把 add、commit、reset、merge 一次讲透
git·github·编程·编程语言
水饺编程3 天前
第1章:开发环境搭建,在 Windows 中安装 Git
linux·c语言·汇编·git·ubuntu
idanzk3 天前
Git 推送 GitHub 报 SSL_READ /src refspec main 不匹配 完整踩坑记录
git·github·ssl
星恒随风3 天前
Linux开发工具详解(二):Git版本控制、GitHub协作与GDB调试实战
linux·笔记·git·学习·github
寺中人4 天前
Xshell 完全入门指南:从安装到实战,远程连接+文件传输+会话管理全拆解
git·ssh·github·php·远程连接·xshell·运维工具