Linux ssh-keygen命令

Linux ssh-keygen命令:创建SSH密钥。

Linux ssh-keygen命令 功能描述

使用ssh-keygen命令可以生成、管理和转换SSH认证密钥。使用SSH v1(SSH协议版本1)创建RSA密钥,使用SSH v2(SSH协议版本2)创建RSA或DSA密钥。使用-t选项指定生成密钥的类型。如果不带任何选项,使用ssh-keygen命令会生成用于SSH v2连接的RSA密钥。

Linux ssh-keygen命令 语法

ssh-keygen [选项]

选项含义:
命令中各选项的含义如表所示。



ssh-keygen命令选项含义

Linux ssh-keygen命令 示例

显示主机rhel的公钥文件的SSHFP指纹资源记录

[root@rhel ~]# ssh-keygen -r rhel
rhel IN SSHFP 1 1 bdd55e705c1e38de7b4c7d570acbe9e8efde3d66
rhel IN SSHFP 2 1 bec42963f462f58ae0dc974e153f7d5dcf72e4cd

创建ssh认证密钥,指定密钥文件为/root/.ssh/known_hosts

[root@rhel ~]# ssh-keygen -f /root/.ssh/known_hosts
Generating public/private rsa key pair.
Enter passphrase(empty for no passphrase):                     //输入密码
Enter same passphrase again:                               //再次输入密码
Your identification has been saved in /root/.ssh/known_hosts.
Your public key has been saved in /root/.ssh/known_hosts.pub.
The key fingerprint is:
05:28:4b:ce:58:9d:e8:1d:1b:9d:53:68:ac:d6:f7:95 root@rhel
The key's randomart image is:
+--[ RSA 2048]----+
|    o=.+.     |
|   =*B.      |
|  B+B..   . |
|  . ==...  E  |
|    .  S. . .   |
|          .   |
|              |
|              |
|              |
+-----------------+

创建RSA密钥

[root@rhel ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key(/root/.ssh/id_rsa):       //直接按回车键使用默认文件保存密钥
Created directory '/root/.ssh'.
Enter passphrase(empty for no passphrase):             //输入密码
Enter same passphrase again:                       //再次输入密码
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
ad:23:c6:c6:c0:54:63:00:be:d6:40:3f:1c:4f:c7:f4 root@rhel
The key's randomart image is:
+--[ RSA 2048]----+
|  o.o.=oo       |
|oo*o..      |
|  o=.  E     |
|  *.  .      |
|  o+  S.     |
|.  +  .      |
|     *o       |
|    o. .      |
|              |
+-----------------+
赞(0)
未经允许不得转载:极客笔记 » Linux ssh-keygen命令
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址