配置多公钥在多平台使用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
相关推荐
蜜汁小强7 小时前
macOS 上的git代理配置在哪里
git·macos·代理模式·proxy模式
钟佩颖8 小时前
Git .
git
Zhongyi_Li20 小时前
git merge的一些记录
git
沛沛老爹1 天前
Web开发者转型AI:Agent Skills版本控制与管理实战——从Git到AI技能仓库
java·前端·人工智能·git·架构·rag
子琦啊1 天前
极速移除 Git 历史中的大文件,告别 git filter-branch太慢的问题
git
儒雅的晴天1 天前
git笔记
笔记·git
Ama_tor1 天前
git bash|下载、安装与配置(Windows11)
git
惜__缘1 天前
Git项目迁移的坑点
git
阿杰 AJie1 天前
Git 分支与多人开发使用指南(Gitee + 本地 Git)
git·elasticsearch·gitee
论迹1 天前
【Git】-- 解决git branch -a打印已被删除的远程分支
git