
puttygen生成公私钥
Puttygen is used to generate ssh public and private keys for putty. We can use a different type of encryption algorithm bit sizes and ssh versions. In this tutorial, we will look at useful examples of puttygen.
Puttygen用于生成SSH的SSH公钥和私钥。 我们可以使用其他类型的加密算法,位大小和ssh版本。 在本教程中,我们将看一些有用的Puttygen示例。
将Puttygen安装到Linux (Install Puttygen To Linux)
puttygen is provided with putty packages most of the Linux distributions like Ubuntu, Debian, Fedora, CentOS, RedHat.
puttygen提供了大多数Linux发行版中的putty软件包,例如Ubuntu,Debian,Fedora,CentOS,RedHat。
Ubuntu,Debian (Ubuntu, Debian)
puttygen
tool is provided with the putty
package in Debian, Mint, Ubuntu, Kali.
在Debian,Mint,Ubuntu,Kali的putty
软件包中提供了puttygen
工具。
$ sudo apt install putty

Fedora,CentOS,RedHat (Fedora, CentOS, RedHat)
puttygen
tool is provided with the putty
package in Fedora, CentOS, RedHat.
Fedora,CentOS和RedHat中的putty
软件包随附了puttygen
工具。
$ sudo yum install putty
视窗 (Windows)
Windows binaries are provided with the following URL.
Windows二进制文件带有以下URL。
32位 (32 bit)
https://the.earth.li/~sgtatham/putty/latest/w32/puttygen.exe
https://the.earth.li/~sgtatham/putty/latest/w32/puttygen.exe
64位 (64 bit)
https://the.earth.li/~sgtatham/putty/latest/w64/puttygen.exe
https://the.earth.li/~sgtatham/putty/latest/w64/puttygen.exe
puttygen命令语法 (puttygen Command Syntax)
The syntax of puttygen is like below. puttygen is a simple command where there are two parameters named KEYFILE, OPTIONS.
puttygen的语法如下。 puttygen是一个简单的命令,其中有两个名为KEYFILE,OPTIONS的参数。
puttygen KEYFILE OPTINONS
KEYFILE
is the file we readKEYFILE
是我们读取的文件OPTIONS
are used to specify size, output key file, etc.OPTIONS
用于指定大小,输出密钥文件等。
从puttygen GUI创建密钥 (Create Key From puttygen GUI)
puttygen tool is provided with a GUI in Windows operating systems. We can download this GUI tool which is explained in the Download For Windows section. Then from the tool, we will be provided a simple screen where we can set different parameters about the cryptographic key creation.
Windows操作系统中的GUI附带了puttygen工具。 我们可以下载此GUI工具,这在Windows的下载部分中进行了说明。 然后,通过该工具,我们将提供一个简单的屏幕,其中我们可以设置有关密码密钥创建的不同参数。

We can see that there is 3 main part of the window.
我们可以看到窗口有3个主要部分。
Key
part provides the key in ASCII format.Key
部分以ASCII格式提供密钥。Actions
part will provide buttons for Key generation, Load Existing Key, Save Public Key, Save Private Key.Actions
部分将提供用于生成密钥,加载现有密钥,保存公共密钥,保存私有密钥的按钮。Parameters
part provides the key type selection likeRSA
,DSA
,ECDSA
,ED25519
,SSH-1 (RSA)
, and the size of the key as bits where default size is 2048 which is accepted as secure.Parameters
部分提供了密钥类型选择,例如RSA
,DSA
,ECDSA
,ED25519
,SSH-1 (RSA)
,以及密钥的大小(以位为单位),默认大小为2048,可以接受此保护。
使用Puttygen GUI创建2048个RSA密钥 (Create 2048 RSA Key with Puttygen GUI)
We can generate an RSA key which is 2048 bit by using the following configuration for the puttygen. We will click on the Generate
button with the default parameters. As cryptography and security are based randomness puttygen need real random data that can be provided with the random mouse hovering over the screen.
我们可以通过对puttygen使用以下配置来生成一个2048位的RSA密钥。 我们将单击带有默认参数的Generate
按钮。 由于密码学和安全性是基于随机性的,因此腻子需要真正的随机数据,这些数据可以通过鼠标悬停在屏幕上来提供。

At the end of the key generation, the following screen will appear where information about the generated key will be presented.
在密钥生成结束时,将出现以下屏幕,其中将显示有关所生成密钥的信息。

Key fingerprint
is a value that uniquely identifies the created key.Key fingerprint
是唯一标识创建的密钥的值。Key comment
is a short description of the created key.Key comment
是对创建的键的简短描述。Key passphrase
is a passphrase or password to encrypt the created key.Key passphrase
是用于加密创建的密钥的密码短语或密码。
We can also create different types and sizes of the keys by changing parameters like below.
我们还可以通过更改如下所示的参数来创建不同类型和大小的键。
- Create 2048 DSA Key with Puttygen GUI 使用Puttygen GUI创建2048 DSA密钥
- Create 4096 RSA Key with Puttygen GUI使用Puttygen GUI创建4096个RSA密钥
- Create 4096 DSA Key with Puttygen GUI使用Puttygen GUI创建4096个DSA密钥
将现有密钥加载到Puttygen GUI(Load Existing Key To Puttygen GUI)
We can load existing puttygen generated key or key pairs easily. We will use the Load
button where we can specify the key file.
我们可以轻松加载现有的puttygen生成的密钥或密钥对。 我们将使用“ Load
按钮来指定密钥文件。

将生成的公钥保存到文件 (Save Generated Public Key To A File)
After creating a Public and Private Key Pair we can save these created keys. We can save generated Public Key into a file with the Save public key
.
创建公钥和私钥对后,我们可以保存这些创建的密钥。 我们可以使用Save public key
将生成的Public Key保存到文件中。

将生成的私钥保存到文件(Save Generated Private Key To A File)
We can also save the generated Private Key into the file with the Save private key
button like below.
我们还可以使用“ Save private key
按钮将生成的私钥保存到文件中,如下所示。

从命令行使用默认选项创建密钥(Create Key with Default Options From Command Line)
We can generate keys with the following command. In this example, we will generate an RSA type key file named test.ppk
. ppk
is the extension of the putty keys.
我们可以使用以下命令生成密钥。 在此示例中,我们将生成一个名为test.ppk
的RSA类型密钥文件。 ppk
是油灰键的扩展名。
$ puttygen -t rsa -o test.ppk
从命令行设置密钥大小 (Set Key Size From Command Line)
We have the option to set the size of the putty key. More in size means more secure but less performance. But the performance loss is negligible. We can set the size with -b
option. We will provide size as a bit unit. In this example, we will set the key file size 4096
bit .
我们可以选择设置油灰键的大小。 更大的尺寸意味着更安全,但性能更低。 但是性能损失可以忽略不计。 我们可以使用-b
选项设置大小。 我们将以位为单位提供尺寸。 在此示例中,我们将设置密钥文件大小4096
bit。
$ puttygen -t rsa -b 4096 -o test.ppk
从命令行更改密码 (Change Passphrase From Command Line)
Keys are protected with symmetric encryption. This means ppk
keys are encrypted and we need to use a passphrase. We can also change the current passphrase with -P
option. In order to change the existing passphrase, we should provide old passphrases too.
密钥受对称加密保护。 这意味着ppk
密钥已加密,我们需要使用密码短语。 我们还可以使用-P
选项更改当前密码。 为了更改现有的密码短语,我们也应该提供旧的密码短语。
$ puttygen mykey.ppk -P
从命令行设置注释为键 (Set Comment To Key From Command Line)
In the enterprise environment, we may have multiple keys where we cannot remember actually what it was. Or we may need to put some comment about keys on the key file. We can use –C
and the comment we want to set.
在企业环境中,我们可能有多个键,我们无法真正记住它是什么。 或者,我们可能需要在密钥文件上对密钥进行一些评论。 我们可以使用– C
和我们要设置的注释。
$ puttygen mykey.ppk -C "My key"
翻译自: https://www.poftut.com/generate-putty-keys-wit-puttygen/
puttygen生成公私钥