git 命令行配置公钥私钥
时间: 2023-07-12 11:04:01 浏览: 76
配置 Git 命令行的公钥私钥可以参考以下步骤:
1. 生成公钥私钥
在命令行中输入以下命令生成公钥私钥:
```
ssh-keygen -t rsa -C "your_email@example.com"
```
其中,`your_email@example.com` 是你的邮箱地址。
2. 将公钥添加到 Git 账户
将生成的公钥(默认在用户目录下的 `.ssh/id_rsa.pub` 文件中)添加到 Git 账户中。具体方法可以参考 Git 官方文档:[添加 SSH 密钥到 Git 账户](https://docs.github.com/cn/github/authenticating-to-github/adding-a-new-ssh-key-to-your-github-account)。
3. 配置本地 Git
在命令行中输入以下命令配置 Git:
```
git config --global user.name "Your Name"
git config --global user.email "your_email@example.com"
```
将 `Your Name` 和 `your_email@example.com` 替换为你的姓名和邮箱地址。
4. 测试连接
在命令行中输入以下命令测试连接:
```
ssh -T git@github.com
```
如果出现以下内容,则表示连接成功:
```
Hi username! You've successfully authenticated, but GitHub does not provide shell access.
```
以上就是配置 Git 命令行的公钥私钥的步骤。
相关推荐
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)