配置多公钥在多平台使用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
相关推荐
℘团子এ6 小时前
git中,项目怎么更换远程仓库连接地址
git
言之。12 小时前
Git Hooks
git
代码AI弗森13 小时前
Git Bash 与 PowerShell:定位差异、使用场景与选择建议
开发语言·git·bash
森叶14 小时前
Git flow command error: ‘flow‘ is not a git command 问题解决
git
天麓15 小时前
git merge 举例
git
AI_567816 小时前
Git冲突治理白皮书:智能标记与可视化协同的下一代解决方案
大数据·人工智能·git·机器学习
念丶小宇17 小时前
Git常用指令
大数据·git·elasticsearch
CSDN_RTKLIB18 小时前
Git Clone
git
中二病码农不会遇见C++学姐18 小时前
.env 文件是干啥的?为什么不能提交到 Git?
git·学习
CoderJia程序员甲19 小时前
GitHub 热榜项目 - 日榜(2026-02-03)
git·ai·开源·llm·github