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參數說明

而且這個注釋其實就在 ~\.ssh\id_rsa.pub 文本內容末尾。

其實到這里讀者會發現,SSH 並不是 git 的命令。在 windows 下安裝 git for windows 時,順帶一起安裝了MSysGit,並提供了SSH軟件包(參見git說明文檔——服務器上的 Git - 生成 SSH 公鑰)。ssh-keygen - t rsa -C "your content" 中的 "your content" 也與 git 用戶名和郵箱沒有任何關系。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM