ssh-keygen -t rsa -C "content" 解释

在使用 git 时难免用到 ssh-keygen - t rsa -C "your content" 这样的命令。而且很多网站如 gitee 会提示在 "your content " 中输入自己的邮箱地址,即 "email@host.com" 之类。

因为笔者在服务器中并未设置 git 的 username 和 email ,所以心存疑问,这里的邮箱地址依据为何?在网上搜索后恍然大悟,这里的 "your content" 并非邮箱地址,而是一个注释。

每次生成密钥,看到国内的博客,都要求输入邮箱。但不知道意义何在。

后来在stackOverFlow上看到这个答案。

The email is only optional field to identify the key.
邮箱仅仅是识别用的key

When you create the ssh you type (for example):
ssh-keygen -t rsa -C “any comment can be here”
当你创建ssh的时候

-t = The type of the key to generate
密钥的类型
-C = comment to identify the key
用于识别这个密钥的注释
So the Comment is for you only and you can put anything inside.
Many sites and software are using this comment as the key name.
所以这个注释你可以输入任何内容,很多网站和软件用这个注释作为密钥的名字

引用链接:ssh-keygen的-C后面的邮箱有什么用?

关于 ssh-keygen 更多参见:ssh-keygen基本用法

关于 ssh 参数更多参见:ssh-keygen参数说明

而且这个注释其实就在 ~.sshid_rsa.pub 文本内容末尾。

其实到这里读者会发现,SSH 并不是 git 的命令。在 windows 下安装 git for windows 时,顺带一起安装了MSysGit,并提供了SSH软件包(参见git说明文档——服务器上的 Git - 生成 SSH 公钥)。ssh-keygen - t rsa -C "your content" 中的 "your content" 也与 git 用户名和邮箱没有任何关系。

原文地址:https://www.cnblogs.com/xunzhiyou/p/12117261.html