配置多公钥在多平台使用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
相关推荐
知识汲取者1 小时前
Git撤销操作全解析:revert、undo与drop commit的区别与应用
git
cxxx176 小时前
【同步Overleaf, Github】
git·overleaf
染翰7 小时前
Linux root用户安装配置Git
linux·git·后端
老虎海子7 小时前
从零手搓一个 AI 编程助手:Mini Claude Code 完全指南
人工智能·git·vscode·python·github
Cat_Rocky8 小时前
CICD-Git简单学习 操作流程后续补
git·学习
存在的五月雨8 小时前
Git的操作
git
丶Darling.8 小时前
Git 初学者使用手册
git
乐于分享的阿乐10 小时前
Git下载安装与零基础使用完整教程
git
东北甜妹10 小时前
DevOps 和 Git,Gitlab
git·gitlab·devops
console.log('npc')10 小时前
git发版上线的时候,打tag标签方便jenkins部署
运维·git·jenkins