Batch deployment of ssh authentication I think that when we build a hadoop cluster, everyone will encounter a problem. manually configure ssh two-way authentication. When the cluster size is very small, we can still endure it, but should I manually configure dozens or even hundreds of nodes? Therefore, we recommend that you use scripts to solve this problem in batches. There are a lot of related answers on the network, but they are not very easy to use. Here, we will record them. 1, install required rpm package, tcl-8.4.13-3.ML5.x86_64.rpm, expect-5.43.0-8.el5.x86_64.rpm, I use linux for redhat6.1 x86_64, tested no problem 2, script code Java code #! /Bin/bash #2013-09 # create a local public key if [! -D/root /. ssh]; then login CT-c "spawn ssh-keygen-t dsa login CT {\" * key * \ "{send \" \ r \"; exp_continue} \ "* passphrase * \" {send \ "\ r \"; exp_continue} \ "* again * \" {send \ "\ r \";}} "fi ssh-add ~ /. Ssh/id_dsa # private key to be manually loaded # create for p in batch ssh authentication $ (cat/root/ip.txt) absolute path of the ip.txt file do ip =$ (echo "$ p" | cut-f1-d ":") secret to obtain the IP address password in the ip.txt File $ (echo "$ p" | cut-f2-d ":") obtain the password in the ip.txt file # verify CT automatically starts to interact with each other and starts verify CT-c "spawn ssh-copy-id-I/root /. ssh/id_dsa.pub root @ $ ip Route CT {\ "* yes/no * \" {send \ "yes \ r \"; exp_continue} \ "* password * \" {send \ "$ password \ r \"; exp_continue} \ "* Password * \" {send \ "$ password \ r \";}} "ssh root @ $ ip '/root/slave_master.sh' # Call the remote script done 3. ip.txt to deploy the ip address + password Java code 10.185.224.105: 123456 10.185.224.104: 123456 10.185.224.103: 123456 4, it means there is no difference between scripts on the remote node and the local script. You need to use scripts to copy the remote script before deployment.