1. On the server (192.168.147.132) and client (192.168.147.133), enter the .ssh directory
and take the server (192.168.147.132) as an example:
cd ~/.ssh
2、 执行生成密钥命令
命令行 [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
3. Copy the above server public and private key id_rsa.pub to the client and save it as the address of authorized_keys:
/root/.ssh/authorized_keys
scp /root/.ssh/id_rsa.pub 192.168.147.133:/root/.ssh/authorized_keys
4. Check whether the client file is copied successfully, and log in directly on the server after the copy is successful
[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
shows that the login is successful!