Git 生成 SSH 公钥

warning: 这篇文章距离上次修改已过793天,其中的内容可能已经有所变动。

071305064859837.png071305064859837.png

SSH 存储位置

默认情况下,用户的 SSH 密钥存储在其 ~/.ssh 目录下。(CentOS 存储在 /root/.ssh;Windows 存储在 C:\Users\Administrator\.ssh)

查看目录下是否存在 SSH 公钥:

$ cd ~/.ssh
$ ls
authorized_keys2  id_dsa       known_hosts
config            id_dsa.pub

id_dsa 或 id_rsa 文件应该成对出现,其中一个带有 .pub 扩展名。.pub 文件是你的公钥,另一个则是私钥。

运行 ssh-keygen 生成

ssh-keygen -t rsa -C "your@example.com"

your@example.com 是你的邮箱。

测试连通性

ssh -T git@github.com

配置 name 和 email

git config --global user.name "yourname"
git config --global user.email "your@example.com"
git , ssh
最后修改于:2022年05月05日 05:59

添加新评论