使用ssh-keygen生成密钥

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]-----+

参考:

原文地址:https://www.cnblogs.com/ghj1976/p/shi-yongsshkeygen-sheng-cheng-mi-yao.html