配置多公钥在多平台使用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
相关推荐
qinqinzhang41 分钟前
代码管理仓库(Git Submodules + Worktree)
git
lilili也4 小时前
Git、VScode、GitLab
git·vscode·gitlab
拥春飞翔4 小时前
AI 生成测试用例:测试知识库选「开源向量库」还「Git+Markdown」?
人工智能·git·测试用例
普修罗双战士5 小时前
高效使用 Git:从入门到精通的实战指南
java·git
摇滚侠6 小时前
创建 git 忽略文件 忽略 .obsidian 这个目录
大数据·git·elasticsearch
studytosky7 小时前
【高并发内存池】线程缓存核心原理与实现
linux·服务器·git·缓存
咕咕嘎嘎10247 小时前
问卷系统测试报告
git
水无痕simon8 小时前
04 Git基础-记录每次更新到仓
git
无限进步_8 小时前
【C++】寻找数组中出现次数超过一半的数字:三种解法深度剖析
开发语言·c++·git·算法·leetcode·github·visual studio
一个程序猿老马19 小时前
012、远程协作:连接GitHub/Gitee与git remote
git·gitee·github