os 版本
Red Hat Enterprise Linux Server release 6.8
配置环境
prod01 192.168.0.230
prod04 192.168.0.197
配置root 对等性
主要命令:ssh-keygen ,ssh-copy-id
配置过程
[root@prod01 ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
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:
08:36:39:c3:9a:92:c0:ea:a0:f3:8f:87:2f:79:9a:2c root@prod01
The key's randomart image is:
+--[ RSA 2048]----+
| |
|. . . |
|.. O |
|o. + = . |
|= o . S |
|+. |
|o. o |
|E++oo |
| .*Bo |
+-----------------+
[root@prod01 ~]#
[root@prod01 ~]#
[root@prod01 ~]# ssh-copy-id 192.168.0.230
The authenticity of host '192.168.0.230 (192.168.0.230)' can't be established.
RSA key fingerprint is a5:27:79:df:14:ab:fe:83:10:ad:59:14:b3:d2:ec:0d.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.0.230' (RSA) to the list of known hosts.
root@192.168.0.230's password:
Now try logging into the machine, with "ssh '192.168.0.230'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
[root@prod01 ~]#
[root@prod01 ~]# scp -r ^C
[root@prod01 ~]# pwd
/root
[root@prod01 ~]# scp -r .ssh/ 192.168.0.197:/root/
The authenticity of host '192.168.0.197 (192.168.0.197)' can't be established.
RSA key fingerprint is ca:a4:56:1e:6d:4f:b1:5f:c0:e1:55:47:6d:9b:5b:22.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.0.197' (RSA) to the list of known hosts.
root@192.168.0.197's password:
id_rsa.pub 100% 393 0.4KB/s 00:00
id_rsa 100% 1679 1.6KB/s 00:00
authorized_keys 100% 393 0.4KB/s 00:00
known_hosts 100% 790 0.8KB/s 00:00
[root@prod01 ~]# ssh 192.168.0.197 date
Wed Nov 28 09:36:28 CST 2018
[root@prod01 ~]# ssh 192.168.0.230 date
Wed Nov 28 09:36:32 CST 2018
[root@prod01 ~]#
测试连通性
#PROD01
[root@prod01 ~]# ssh 192.168.0.230 date
[root@prod01 ~]# ssh 192.168.0.230 date
Wed Nov 28 09:37:15 CST 2018
[root@prod01 ~]# ssh 192.168.0.197 date
Wed Nov 28 09:37:20 CST 2018
#PROD04
[root@prod04 ~]# ssh 192.168.0.197 date
Wed Nov 28 09:38:01 CST 2018
[root@prod04 ~]# ssh 192.168.0.230 date
Wed Nov 28 09:38:04 CST 2018
[root@prod04 ~]#