配置多公钥在多平台使用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
相关推荐
Unity粉末状在校生4 小时前
Git解决fatal: Could not read from remote repository.的问题
git
少年攻城狮5 小时前
Obsidian系列---【如何使用obsidian同步到git?】
git
do better myself7 小时前
网站源码如何部署和加入GIT仓库的
git
爱学英语的程序员10 小时前
Git 提交 LF will be replaced by CRLF the next time Git touches it 报错
git
qq_3391911410 小时前
服务器git pull每次都要输入密码,linux 设置git登录,linux设置git只输入一次账户密码
git
一颗小行星!16 小时前
快速理解 Git submodule
git
A-Jie-Y19 小时前
Git基础-核心概念与常用命令
git
夜珀19 小时前
Git基础修炼手册:在AtomGit上玩转版本控制
git
golang学习记19 小时前
Zed IDE官宣新招:Git Graph 正式支持!
ide·git
要记得喝水20 小时前
适用于 Git Bash 的脚本,批量提交和推送多个仓库的修改
git·elasticsearch·bash