配置多公钥在多平台使用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
相关推荐
NaCl鱼呜啦啦11 小时前
Git 仓库损坏修复指南:从诊断到恢复
git
huazi9912 小时前
AI编程(一):Trae+Git 应用开发
git·ai编程·trae
badhope14 小时前
GitHub热门AI技能Top20实战指南
前端·javascript·人工智能·git·python·github·电脑
m0_6356474816 小时前
git管理github上的repository(三)
git·github
圥忈&&丅佽&&扗虖16 小时前
ubuntu 安装git
linux·git·ubuntu
好运yoo18 小时前
git fetch和git pull的区别
大数据·git·elasticsearch
薛不痒18 小时前
github基础入门(3):版本控制(提交,分支删除,提交规范)
大数据·windows·git·elasticsearch·github
摇滚侠1 天前
git 把已经推送到远程仓库的文件取消被 git 管理
git
007张三丰1 天前
掌握核心!Git最常用的15个命令行:从入门到实战详解
git·gitlab·github·git命令行·常用命令行
月光下的麦克1 天前
Git 打 Tag 的作用
git