配置多公钥在多平台使用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
相关推荐
梓沂28 分钟前
pycharm Git 连接 GitHub 报错全记录:从 SSL 证书到 SSH 密钥,一步步踩坑与解决
git·pycharm·github
无小道35 分钟前
Git版本控制及其原理:从入门到精通
git·企业
颂love1 小时前
Git的简单学习
git·学习
一个学Java小白1 小时前
git 如何免密提交之 基于 Gitee 的 SSH 配置教程
git
我是谁??1 小时前
ubuntu22.04在线安装docker和nvidia-container-toolkit
git·docker·github
Kessity1 小时前
Git标签管理
git
悟空瞎说20 小时前
Git Worktree 实战:多 AI 编码代理并行开发,彻底解决分支切换冲突痛点
前端·git
BING_Algorithm1 天前
开发常用Git核心知识
git·后端
Lyyaoo.1 天前
Git常用命令及应用
git