Description
- There are currently 4 Redhat Linux operating systems installed, with host names of HADOOP01,HADOOP02,HADOOP03,HADOOP04
- Where HADOOP01 is the primary node and hadoop02,hadoop03,hadoop04 is the slave node
- Four node IP address is 192.168.10.61~64.
- If you do not modify the Hosts file, you can change the hadoop01~04 to the corresponding IP address from the second step, such as the SCP ~/.ssh/id_rsa.pub in step 4th [email protected]:~ command can be changed to SCP ~/ . ssh/id_rsa.pub [Email protected]:~
1th Step: The Hosts file modification (optional)
If you want to access the remaining nodes in the future by using the ssh hostname , make sure that the hosts file on each node has mappings for each IP and host name, which can be viewed with the following command
cat /etc/hosts
If the IP address does not correspond to the host name, modify the Hosts file as shown above
vim /etc/hosts
2nd step: Generate a key pair
Execute the following command on each node to generate the key pair, always click Enter to
ssh-keygen-t-P‘‘
3rd step: Native SSH access
Execute the following command on each node to write the public key file to the authorization file and assign the permissions
cat ~/.ssh/id_rsa.pub >> ~/.ssh600 ~/.ssh/authorized_keys
On each node can be verified by entering the two SSH node hostname command (note that the first SSH node hostname will ask, enter Yes, you will not need to enter a password in the future)
4th Step: Master node to slave node without password SSH access
Execute the following command on the master node to copy the primary node's public key file to the slave node (note that the password for the input node is required when making a remote copy)
scp ~/.ssh/id_rsa.pub root@hadoop02:~scp ~/.ssh/id_rsa.pub root@hadoop03:~scp ~/.ssh/id_rsa.pub root@hadoop04:~
Append the main node's public key to the authorization file by executing the following command from the node
cat ~/id_rsa.pub >> ~/.ssh600 ~/.ssh/authorized_keysrm ~/id_rsa.pub
Execute the following command in the Master node to implement no password access from the primary node to the slave node
ssh hadoop02exitssh hadoop03exitssh hadoop04exit
5th step: No password SSH access from the node to the master node
Execute the following command on each slave node to implement no password access from the node to the master node
cd cd .sshssh-copy-id -i id_rsa.pub [email protected]
Execute the following command on each slave node to verify that there is no password SSH access from the node to the master node.
ssh hadoop01
Free key access between multiple nodes under Linux