共三步:
一、生成一对密匙
二、发送密匙到其他机器上
比如有4台Linux机器需要互通SSH,则每台机器上需要执行下面红色指令3次(针对其余3台机器,指令中IP改成其他3台机器IP)。password处输入root用户密码
三、操作完毕,登陆检查。
一、以root用户执行下述命令:
[root@localhost .ssh]# /usr/bin/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:
30:f6:d7:2a:ac:56:eb:3f:fa:40:25:8d:90:96:68:cb root@localhost.localdomain
该命令将在用户的主目录/.ssh目录下面产生一对密钥
一般采用的ssh的rsa密钥:
id_rsa 私钥
id_rsa.pub 公钥
二、[root@localhost .ssh]# scp /root/.ssh/id_rsa.pub root@172.16.142.5:/root/.ssh/authorized_keys
The authenticity of host '172.16.142.5 (172.16.142.5)' can't be established.
RSA key fingerprint is 4b:a5:74:fb:2e:08:60:af:fa:76:d4:b0:26:4c:13:75.
Are you sure you want to continue connecting (yes/no)?yes
Warning: Permanently added '172.16.142.5' (RSA) to the list of known hosts.
root@172.16.142.5's password:
id_rsa.pub
三、[root@localhost .ssh]# ssh 172.16.142.5
root@172.16.142.5's password: