配置多公钥在多平台使用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
相关推荐
洛菡夕20 小时前
NoSQL之Redis配置与优化
redis·git·nosql
游九尘1 天前
git只忽略自己本地的文件,其他人的文件正常提交
git
SiYuanFeng1 天前
新手学Git:以一个小游戏项目为例,完成初始化、提交、查看历史与恢复版本
大数据·git·elasticsearch
rayyy91 天前
Git 忽略已提交过的文件夹 完整步骤
git
YoseZang1 天前
【手工】git的使用 - 密钥生成和多账户使用(config文件)
git
韭菜钟1 天前
Git 代理与内网 Gitea 共存方案(无需 no_proxy)
git·gitea
zhougl9961 天前
Git 命令速查手册
大数据·git·elasticsearch
小陈同学呦1 天前
Git Worktree 并行开发实战指南
git·vibecoding
码农小旋风1 天前
2026 最新 Claude Code Windows 安装教程:Node、Git Bash、命令检查一步步配好
windows·git·bash·claude
ethan.Yin1 天前
Git_查看已删除文件的历史
git