一、 分别在服务端(192.168.147.132)和客户端(192.168.147.133),进入.ssh目录
下面以服务端(192.168.147.132)为例:
cd ~/.sshdom
二、 执行生成密钥命令
命令行 [ssh-keygen -t rsa]
[root@bogon /]# ssh-keygen -t rsa
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:
53:7d:f0:f4:6d:42:77:59:b5:8a:d7:76:3e:18:fe:82 root@bogon
The key's randomart image is:
+--[ RSA 2048]----+
| . o O|
| . = ++|
| . . +.+|
| . ..oo |
| S . + o.|
| . o +..|
| .o ..|
| E .. .|
| .. |
+-----------------+
[root@bogon /]# ls /root/.ssh/
id_rsa id_rsa.pub
三、 将以上服务端公私密钥 id_rsa.pub 复制到 客户端并保存为authorized_keys的地址:ssh
/root/.ssh/authorized_keys
scp /root/.ssh/id_rsa.pub 192.168.147.133:/root/.ssh/authorized_keys
四、 查看客户端文件是否复制成功,复制成功后直接在服务端直接登陆
[ssh 192.168.147.133]
[root@bogon .ssh]# ssh 192.168.147.133
Last login: Tue Apr 3 10:54:45 2018 from 192.168.147.132
显示登陆成功!ide