配置多公钥在多平台使用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
相关推荐
周杰伦fans5 小时前
如何将 Feature 分支同步到 Master 主分支:一次完整的 Git 合并实战
git
jiayi_19995 小时前
git创建new branch
git
__Witheart__6 小时前
通过交互式 Rebase 合并部分提交到远程分支的操作步骤
git
魔都吴所谓7 小时前
【Tools】Repo 工具完整使用手册
git
tianyuanwo7 小时前
跨 Gerrit 项目迁移分支并保留完整历史:一份可操作的 Git 指南
git·代码迁移
玄奕子7 小时前
VS Code 上传 GitHub 全流程(Windows 环境):HTTP 与 SSH 两种方案(含常见报错排查)
git·http·ssh·github·嵌入式开发
一只游鱼7 小时前
如何让本地的敏感配置文件不上传到git仓库
git·elasticsearch
渣渣馬20 小时前
shell的if多条件
git·ssh
zh_xuan20 小时前
Visual Studio 上传工程到github
ide·git·github·visual studio
AntoineGriezmann1 天前
Git 学习笔记
git