配置多公钥在多平台使用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
相关推荐
C++ 老炮儿的技术栈1 小时前
C/C++ 中 inline(内联函数)和宏定义(#define)的区别
开发语言·c++·git·算法·机器人·visual studio
Async Cipher3 小时前
Git 安装、配置
git
CoderJia程序员甲7 小时前
GitHub 热榜项目 - 日榜(2026-01-24)
git·ai·开源·llm·github
莫问前路漫漫7 小时前
Electerm 连接远程服务器完整指南
运维·服务器·git
鸣弦artha8 小时前
TabBar标签页组件详解
linux·git·ubuntu
小林up12 小时前
Ubuntu访问不了Git解决办法
linux·git·ubuntu
月初,1 天前
Git 常用操作大全(超详细教程)一文教会你完全使用Git
大数据·git·elasticsearch
李少兄1 天前
Git 忽略文件机制:.gitignore 与 .git/info/exclude
java·git·elasticsearch
github.com/starRTC1 天前
Claude Code中英文系列教程17:将Claude Code集成在GitLab工作流里面
git·gitlab·github
CCC:CarCrazeCurator1 天前
git merge与rebase的区别及实操心得体会
git