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 /]#
查看生成公钥的目录:
[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 ~]#
至此,公钥创建完毕~