1.3台机器执行 [root@hadoop001 ~]# 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: 74:78:50:05:7e:c8:bb:2a:f1:45:c4:0a:9c:38:90:dc root@hadoop001 The key's randomart image is: +--[ RSA 2048]----+ | ..+ o ..ooo. | | o E + =o. | | . .oo* . | | ..o.o | | S.. | | . .. | | o .. | | . .. | | .. | +-----------------+ [root@hadoop001 ~]# cat /root/.ssh/id_rsa.pub>> /root/.ssh/authorized_keys
4.将authorized_keys分发到hadoop002、hadoop003机器 [root@hadoop001 .ssh]# scp authorized_keys 192.168.137.131:/root/.ssh/ The authenticity of host '192.168.137.131 (192.168.137.131)' can't be established. RSA key fingerprint is 76:c7:31:b6:20:56:4b:3e:29:c1:99:9f:fb:c0:9e:b8. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.137.131' (RSA) to the list of known hosts. root@192.168.137.131's password: authorized_keys 100% 1188 1.2KB/s 00:00 [root@hadoop001 .ssh]# scp authorized_keys 192.168.137.132:/root/.ssh/ The authenticity of host '192.168.137.132 (192.168.137.132)' can't be established. RSA key fingerprint is 09:f6:4a:f1:a0:bd:79:fd:34:e7:75:94:0b:3c:83:5a. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.137.132' (RSA) to the list of known hosts. root@192.168.137.132's password: authorized_keys
5.验证(每台机器上执行下面3条命令,只输入yes,不输入密码,则这3台互相通信了) ssh root@hadoop001 date ssh root@hadoop002 date ssh root@hadoop003 date
1.3台机器执行[root@hadoop001 ~]# ssh-keygenGenerating 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...