# == START run ssh cmd and copy files in parallel on multiple hosts
export ssh_user="type_your_ssh_user_here"
#build the host names containing list file
export hosts_file=/tmp/hosts.lst
cat <<EOF > $hosts_file
managementnode1
datanode1
datanode2
datanode3
EOF
# define the name of the file to deploy on the hosts
export file=/etc/ssh/sshd_config
# optionally run any cmd on the hosts
export cmd="sh /opt/anc/anp/sfw/sh/file-saver.sh -f $file"
# run ssh in subshells in parallel and scp the file to all hosts
cat $hosts_file | while read -r host ; do ( \
echo -e "\n\n START $host" ; \
ssh $ssh_user@$host "$cmd" ; \
scp -p $file root@$host:$file \
& )& done ;
# clean-up
rm -fv $hosts_file
# == STOP run ssh cmd and copy files in parallel on multiple hosts
No comments:
Post a Comment
- the first minus - Comments have to be moderated because of the spammers
- the second minus - I am very lazy at moderating comments ... hardly find time ...
- the third minus - Short links are no good for security ...
- The REAL PLUS : Any critic and positive feedback is better than none, so your comments will be published sooner or later !!!!