配置多公钥在多平台使用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
相关推荐
云攀登者-望正茂42 分钟前
将 develop 分支拉取到特性分支时解决合并污染问题
git
金銀銅鐵3 小时前
[git] 如何找到已经“丢失”的 commit?
git·后端
尘世壹俗人4 小时前
linux编译安装git
linux·运维·git
打不了嗝 ᥬ᭄20 小时前
Git 原理与使用
git·gitee
m0_614619061 天前
花了一下午学 Git,整理了一份学习笔记
笔记·git·学习
AGV算法笔记1 天前
解决Git> git add -A -- fatal: CRLF would be replaced by LF in Test/Test.cpp
git
Dontla1 天前
VSCode插件Git Graph介绍(Git可视化管理分支、可视化Git)
ide·git·vscode
Echoo华地1 天前
用git diff快速比较文件夹差异并生成报告
linux·git·unix·repository·diff·branch
勤劳打代码1 天前
防微杜渐 —— 为什么一次 Sync 会变成一次 merge?
git·团队管理
dyxal1 天前
Windows 下 Git 离线安装与 VS Code 便携版集成完全指南
windows·git·elasticsearch