步骤1:使用ssh-keygen命令创建公钥和私钥

[root@model /]# 
[root@model /]# ssh-keygen -t rsa -P ''  
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Created directory '/root/.ssh'.
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:
f4:b3:7f:7f:9c:8a:04:ab:9a:8b:44:1d:b6:85:9d:e0 root@model
The key's randomart image is:
+--[ RSA 2048]----+
|            ..oo.|
|           .  ...|
|        .. = Eo  |
|       .... o    |
|    .. o.o+  .   |
|    =  . .+o=    |
|         ..==O ..|
|       . o.=.. .o|
|       . ... .o. |
+-----------------+
[root@model /]#

查看生成公钥的目录:

[root@model ~]# cd /root/.ssh/
[root@model .ssh]# 
[root@model .ssh]# ls
authorized_keys  id_rsa  id_rsa.pub
[root@model .ssh]# 

步骤2:上传公钥到目标服务器(IP:192.168.1.2)

[root@model ~]# 
[root@model ~]# scp /root/.ssh/id_rsa.pub root@192.168.1.2:/root/.ssh/authorized_keys
root@192.168.1.2's password: #输入目标服务器密码
id_rsa.pub                                                               100%  391     0.4KB/s   00:00    
[root@model ~]#

至此,公钥创建完毕~

相关文章:

  • 2022-12-23
  • 2021-12-12
  • 2022-12-23
  • 2022-01-01
  • 2021-11-09
  • 2021-11-01
  • 2021-05-15
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-05-06
  • 2021-11-02
  • 2021-06-19
  • 2021-09-12
  • 2021-06-05
相关资源
相似解决方案