centos7建立ssh公鑰

步驟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 /]#

查看生成公鑰的目錄:dom

[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)ssh

[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 ~]#

至此,公鑰建立完畢~ide

相關文章
相關標籤/搜索