小蒋同学

Git 生成 SSH 公钥

2019-11-16  本文已影响0人  小蒋同学v
071305064859837.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"
上一篇下一篇

猜你喜欢

热点阅读