配置多公钥在多平台使用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
相关推荐
半个落月10 小时前
从零开始理解 Git 核心操作:告别单机开发的“原始时代”
git
东风破_11 小时前
别学 Git 命令了,先搞懂这仨区域:工作区→暂存区→仓库
git
戴国进11 小时前
详解Git的worktree实现多分支并行开发
大数据·git
凌冰_11 小时前
Claude Code was unable to find CLAUDE_CODE_GIT_BASH_PATH path路径异常解决
git
xlq2232212 小时前
3.git
git
一只大袋鼠1 天前
Git 进阶(二):分支管理、暂存栈、远程仓库与多人协作
java·开发语言·git
我叫张小白。1 天前
Git 分支管理与团队协作
git
DogDaoDao1 天前
Windows 下 Git 报错:`touch` 无法识别 —— 原因分析与 7 种解决方案(从入门到精通)
windows·git·程序员·npm·powershell·cmd·touch
caicai_xiaobai1 天前
Ubuntu上Git安装步骤
linux·git·ubuntu
come112341 天前
git 区分是 Git 分支还是 worktree 路径名
git