配置多公钥在多平台使用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
相关推荐
云泽8081 小时前
Git 版本控制系统(下):从 .git 目录结构到冲突解决机制详解
大数据·git·elasticsearch
麻辣布丁8 小时前
Git冲突原因与解决方法全解
大数据·git·elasticsearch
一支黑色の铅笔12 小时前
VSCode 克隆Git项目
ide·git·vscode
拽着尾巴的鱼儿15 小时前
Idea:Cannot Run Git 无法运行git
java·git·intellij-idea
y小川18 小时前
【git】移除远端已删除的git分支
git
OsDepK1 天前
项目快速Git至仓库(完整版)
大数据·git·elasticsearch·搜索引擎
妙码生花1 天前
使用git更新ai-go-admin框架
前端·人工智能·git·golang·typescript·php
朝阳5811 天前
如何用 AI 自动生成规范的 Git 提交信息:从暂存区 diff 到 Conventional Commit
人工智能·git
hudawei9961 天前
有未保存的修改,不能切换分支
git·git stash·stash
康一夏1 天前
Git Commit 规范实践:Angular Commit 规范 + Commitlint 自动化验证
git·自动化·commit msg·commit规范