配置多公钥在多平台使用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
相关推荐
不爱学英文的码字机器4 分钟前
[Git] 文件删除
git
DZSpace1 小时前
git stash命令用法
git
Vowwwwwww1 小时前
GIT历史存在大文件的解决办法
前端·git·后端
@BreCaspian2 小时前
Git 推送失败解决教程——error: failed to push some refs to
大数据·git·elasticsearch
该换个名儿了6 小时前
git多个commit合并成一个
前端·git
不爱学英文的码字机器6 小时前
[Git] 分布式版本控制 & 远程仓库协作
分布式·git
Stack_guigui7 小时前
git连接本地仓库以及gitee
git·gitee
火车叼位7 小时前
Git 精准移植代码:cherry-pick 简单说明
前端·git
Cynthia-石头10 小时前
Git Github Gitee GitLab
git·gitee·github
ak啊1 天前
Git 撤销操作完全指南:从工作区到远程仓库的救赎之路
git