0
点赞
收藏
分享

微信扫一扫

基于Spring Boot、Mybatis、Redis和Layui的企业电子招投标系统源码实现与立项流程

小月亮06 2023-12-16 阅读 59

gitee 和 github 密钥配置

1. 检查配置信息

使用命令 git config --global --list 检查邮箱是否一致

不一致可以使用如下命令进行设置

git config --global user.name "name"
git config --global user.email "email@qq.com"  

2. 生成 SSH 密钥

# 为 GitHub 生成密钥
ssh-keygen -t rsa -C "your_email@example.com" -f ~/.ssh/id_rsa_github

# 为 Gitee 生成密钥
ssh-keygen -t rsa -C "your_email@example.com" -f ~/.ssh/id_rsa_gitee

一直按回车,出现选择时输入 Y 直到生成一个 .ssh/id_rsa_xxx.pub 文件

使用 cat .ssh/id_rsa_xxx.pub 打开文件并且复制秘钥

3. 添加 SSH 密钥到 SSH 代理

减少密钥输入频率,提高安全性,支持多个密钥,便于远程操作

# 启动 SSH 代理
eval "$(ssh-agent -s)"

# 将 GitHub 密钥添加到 SSH 代理
ssh-add ~/.ssh/id_rsa_github

# 将 Gitee 密钥添加到 SSH 代理
ssh-add ~/.ssh/id_rsa_gitee

4. 将 SSH 公钥添加到 GitHub 和 Gitee

在这里插入图片描述

  • 对于 GitHub,登录你的账户,进入 Settings > SSH and GPG keys > New SSH key,把 ~/.ssh/id_rsa_github.pub 文件的内容粘贴进去。
  • 对于 Gitee,同样登录你的账户,进入设置,找到 SSH 公钥部分,并添加 ~/.ssh/id_rsa_gitee.pub 文件的内容。

5. SSH 配置文件

如果你希望 Git 根据不同的仓库自动选择正确的 SSH 密钥,你可以创建或编辑 ~/.ssh/config 文件,添加类似以下内容:

# GitHub 配置
Host github.com
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_rsa_github

# Gitee 配置
Host gitee.com
  HostName gitee.com
  User git
  IdentityFile ~/.ssh/id_rsa_gitee

6. 验证是否能连通

ssh -T git@github.com
ssh -T git@gitee.com

不通就是
ssh-agent -s
ssh-add ~/.ssh/id_rsa 操作这两步。

举报

相关推荐

0 条评论