
macOS下配置Github & Gitee
0x01 安装Git
1 | brew install git |
0x02 生成密钥对
Github
1 | ssh-keygen -t rsa -b 4096 -C "[email protected]" -f ~/.ssh/id_rsa_github |
Gitee
1 | ssh-keygen -t rsa -b 4096 -C "[email protected]" -f ~/.ssh/id_rsa_gitee |
查看生成公钥
Github
1 | cat ~/.ssh/id_rsa_github.pub |
Gitee
1 | cat ~/.ssh/id_rsa_gitee.pub |
配置GitHub & Gitee公钥
Github
- 登录到 GitHub,进入 Settings -> SSH and GPG keys -> New SSH key,将公钥粘贴进去并保存。
Gitee
- 登录到 Gitee,进入 个人设置 -> SSH 公钥 -> 添加公钥,将公钥粘贴进去并保存。
配置本地SSH文件
1 | vim ~/.ssh/config |
添加以下内容
1 | # GitHub 配置 |
测试连接
测试Github连接
1 | ssh -T [email protected] |
如果成功将看到以下提示信息
1 | Hi 你的用户名! You've successfully authenticated, but GitHub does not provide shell access. |
测试Gitee连接
1 | ssh -T [email protected] |
如果成功将看到以下提示信息
1 | Hi 你的用户名! You've successfully authenticated, but Gitee does not provide shell access. |
测试仓库克隆
Github
1 | git clone [email protected]:username/repository.git |
Gitee
1 | git clone [email protected]:username/repository.git |
- 标题: macOS下配置Github & Gitee
- 作者: Bachelor LEE
- 创建于 : 2025-02-04 12:35:09
- 更新于 : 2025-02-04 12:41:53
- 链接: https://blog.inik.cc/2025/02/04/ae020f00c94a.html
- 版权声明: 本文章采用 CC BY-NC 4.0 进行许可。