配置多公钥在多平台使用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
相关推荐
Serene_Dream2 小时前
git 合并冲突的分支
git
我是一只puppy3 小时前
使用AI进行代码审查
javascript·人工智能·git·安全·源代码管理
玄同7653 小时前
Git常用命令指南
大数据·git·elasticsearch·gitee·github·团队开发·远程工作
十步杀一人_千里不留行6 小时前
Git提交前ESLint校验实践(Husky + lint-staged)
git·github
hh随便起个名9 小时前
适合小白的git的基础使用方法
git
我会一直在的10 小时前
Devps持续集成
git·ci/cd
CoderJia程序员甲11 小时前
GitHub 热榜项目 - 日榜(2026-02-08)
git·ai·开源·llm·github
Serene_Dream12 小时前
git 常用命令
git
jiayong2312 小时前
Detached HEAD 状态详解
git
李少兄1 天前
在 IntelliJ IDEA 中修改 Git 远程仓库地址
java·git·intellij-idea