配置多公钥在多平台使用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
相关推荐
空中海2 小时前
Git-02:协作篇 — 分支工作流、合并变基与远程协作
git
空中海2 小时前
Git-03:专家篇 — 底层原理、故障恢复、性能安全与面试题
git
霜落花轻扬20 小时前
git相关命令
git
xlq223221 天前
2.git
git
OYangxf1 天前
Git Ignore
大数据·git·elasticsearch
哆哆啦001 天前
obsidian远程同步方案:infiniCloud+remotely save方案
笔记·git·obsidian
西柚小萌新1 天前
【计算机常识】--使用 Gitea 在本地/内网搭建 Git 私有服务器
服务器·git·gitea
zhangfeng11331 天前
scp 命令的使用方法 什么软件支持 .git bash xshell .openssh
开发语言·git·bash
_君莫笑1 天前
大厂Git使用规范
git
无心水2 天前
【Hermes:安全、权限与生产环境】39、智能体也会犯错?Hermes 纠错、回滚与遗忘机制全指南 —— 让 AI 的错误像 Git 一样可逆可控
人工智能·git·安全·mcp协议·openclaw·hermes·honcho