ssh-keygen 用於生成、管理和轉換認證密鑰,包括 RSA 和 DSA 兩種密鑰。
- 密鑰類型可以用 -t 選項指定。如果沒有指定則默認生成用於SSH-2的RSA密鑰。
下面使用的參數 -t 也是默認的,可以不用。
這里我們在第三行,我們輸入了 /Users/guohongjun/.ssh/dianping_rsa ,也就是我們所希望的ssh密鑰的名字以及路徑。 其他均選擇的是默認參數回車。
% ssh-keygen -t rsa -C "guohongjun@aaa.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/guohongjun/.ssh/id_rsa): /Users/guohongjun/.ssh/dianping_rsa
Enter passphrase (empty for no passphrase): 回車
Enter same passphrase again: 回車
Your identification has been saved in /Users/guohongjun/.ssh/dianping_rsa.
Your public key has been saved in /Users/guohongjun/.ssh/dianping_rsa.pub.
The key fingerprint is:
SHA256:lkDYKGrjNG+zSB70s9H9BWQ/ynIqIidg8USzJSxYVtU guohongjun@aaa.com
The key's randomart image is:
+---[RSA 3072]----+
|..+..=o. |
|.o.=oo. Eo |
| .o.= . o . |
|.B o . o o |
|= O . . S o . |
|.= O . + + . |
|= + * = . |
| = = . . . |
| + . . |
+----[SHA256]-----+
參考: