配置多公钥在多平台使用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
相关推荐
GISer_Jing2 小时前
Git协作开发:feature分支、拉取最新并合并
大数据·git·elasticsearch
高山莫衣7 小时前
git rebase多次触发冲突
大数据·git·elasticsearch
码农藏经阁7 小时前
工作中常用的Git操作命令(一)
git
kobe_OKOK_8 小时前
【团队开发】git 操作流程
git·elasticsearch·团队开发
码农垦荒笔记8 小时前
Git 安装闭坑指南(仅 Windows 环境)
windows·git
CC码码18 小时前
管理你的多个 Git 密钥(多平台多账号)
git·gitlab·github
CC码码18 小时前
管理你的多个 Git 密钥(单平台多账号)
git·gitlab·github
大卫小东(Sheldon)18 小时前
GIM 1.5发布了! 支持Windows系统了
git·ai·rust
flying jiang18 小时前
将大仓库拆分为多个小仓库
git
李boyang10 天前
Git(四):远程操作
git