配置多公钥在多平台使用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
相关推荐
Python私教13 小时前
AI 并行编码的 Worktree 生命周期:创建、隔离与安全回收
人工智能·git
互联网中的一颗神经元13 小时前
16 — 改写历史 rebase:搬家到新楼层,不是合并
git
互联网中的一颗神经元18 小时前
19 — 贮藏与清理:stash 是抽屉,gc 是打包箱
git
用户3301448676319 小时前
20 — 远程进阶:强制推送的保险绳——force-with-lease
git
Cooper2519 小时前
别急着改 Git 历史:rebase、cherry-pick、bisect 与 reflog 的安全操作顺序
git
刚入门的大一新生21 小时前
Linux-版本控制器Git
git
扶苏100221 小时前
同一个 Git 项目整出两份,切分支互不影响?两种方案实测
大数据·git·elasticsearch
ZJU_统一阿萨姆21 小时前
【Git】Github 开源许可证详解
git·开源·github
Geek-Chow2 天前
Git 标签与发布流程:轻量标签、附注标签与签名标签
git·tags
wear工程师2 天前
Git 冲突怎么解决:别只删标记,先看懂暂存区的 1、2、3 阶段
git