Ssh provides secure access to the remote system. The traffic between systems are encrypted using encryption algorithms. There are different encryption algorithms. RSA
is the most popular asymmetric encryption algorithm. In this tutorial we will look how to create RSA keys with ssh-keygen
Ssh提供对远程系统的安全访问。 系统之间的流量使用加密算法进行加密。 有不同的加密算法。 RSA
是最流行的非对称加密算法。 在本教程中,我们将研究如何使用ssh-keygen
创建RSA密钥
RSA历史(RSA History)
RSA algorithm is created by researchers named Ron Rivest, Adi Shamir and Leonard Adleman in the MIT. And named with their names first letters. It is asymmetric or public encryption algorithm provides a lot of flexibility. We can generate different size of keys with RSA. RSA is used to make secure SSH, OpenGP, S/MIME, SSL/TLS etc.
RSA算法是由麻省理工学院的研究人员Ron Rivest,Adi Shamir和Leonard Adleman创建的。 并以他们的名字首字母命名。 它为非对称或公共加密算法提供了很大的灵活性。 我们可以使用RSA生成不同大小的密钥。 RSA用于制作安全的SSH,OpenGP,S / MIME,SSL / TLS等。
使用Ssh-keygen生成RSA密钥 (Generate RSA Key with Ssh-keygen)
Actually ssh-keygen
will create RSA keys by default. So we do not have to specify the algorithm but in order to be sure and provide information we can explicitly specify the RSA key creation. We will use -t
option in order to specify the RSA algorithm.
实际上, ssh-keygen
默认会创建RSA密钥。 因此,我们不必指定算法,但是为了确定并提供信息,我们可以显式指定RSA密钥创建。 我们将使用-t
选项以指定RSA算法。
$ ssh-keygen -t RSA

生成不同路径的RSA密钥(Generate RSA Key To Different Path)
By default RSA key is generated into user home directory ~/.ssh/id_rsa
. We can change this default directory during the generation or by providing the path as parameter. We will use -f
option in order to change path and file name. We will create key named test
in to the current working directory.
默认情况下,RSA密钥会生成到用户主目录~/.ssh/id_rsa
。 我们可以在生成过程中或通过提供路径作为参数来更改此默认目录。 我们将使用-f
选项来更改路径和文件名。 我们将在当前工作目录中创建名为test
密钥。
$ ssh-keygen -t RSA -f test

There will be two files named;
将有两个文件名为:
test
is the private keytest
是私钥test.pub
is the public keytest.pub
是公钥