(1)执行如下命令,生成公钥
ssh-keygen -t rsa -C
然后连续按回车
[root@iZbp1flzt6x7pxmxfhmxeeZ .ssh]# ssh-keygen -t rsa -C
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
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:
SHA256:tX1404fAO3HS1oXG0xOHuowHVHSV4hIFkAN1k2o51Kc hitredrose2100@
The key's randomart image is:
+---[RSA 2048]----+
| .oo+**o.**|
| +o=.=*++|
| ..= Xo=.o|
| *.E.X o |
| S o+*.= o|
| . ++ ..|
| . |
| |
| |
+----[SHA256]-----+
[root@iZbp1flzt6x7pxmxfhmxeeZ .ssh]#
(2)查看公钥
cat /root/.ssh/id_rsa.pub
如:
[root@iZbp1flzt6x7pxmxfhmxeeZ .ssh]# cat /root/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCuXj1pbpJkEJLX/ktZOtYYSRG3TQRHgh1a03kl0TgX7hKT0sPhtXRVkRBtwEceHW9b8wClklKK64XFgiV1jLr7TbR0jkrDlv06vfsb1hxQwtgIsBandbivxBNm3m4fWLv9ebq/QCPxhLQDG87ks6ZIGQbNxiHbWYfxbqlPXAAZBfUVWVgkpWz86UAxOQBjjVQfTTJ85Bd1OFNjJB7Gt6T1ozp1Tp0Z2Goc6tGkEmiBOqErEADTYv/mE+qVpTANAa6ylbvs8JZbvb44iz84/2fPXS+0hJJ5vsVt35pWZaiDZFIJrJ+mSLwvGEdn2Z7IHBHxc8ANjiR+uZaQaYsZY7xH hitredrose2100@
[root@iZbp1flzt6x7pxmxfhmxeeZ .ssh]#
(3)查看私钥
cat /root/.ssh/id_rsa
如:
[root@iZbp1flzt6x7pxmxfhmxeeZ .ssh]# cat /root/.ssh/id_rsa
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEArl49aW6SZBCS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