Sunday, January 3, 2016

Script for copy files between servers using rsync without asking password

1) We need to install sshpass package in the source server from where we are coping the files

Yum install sshpass-1.05-9.1.x86_64 or rpm -ivh sshpass-1.05-9.1.x86_64

2) write a script like below

#!/bin/bash
for i in `cat /home/muthu/ip1.txt`
do
sshpass -p "Amma#2015" rsync -au /home/muthu/health_check.sh muthu@$i:/home/muthu/
done


Explanation:

 --> cat /home/muthu/ip1.txt this is the file which will contain destination server name list

-->sshpass -p "Amma#2015" - passing password as a argument to sshpass

-->rsync -au /home/muthu/health_check.sh muthu@$i:/home/muthu/ - here $i is the value which is there in the file cat /home/muthu/ip1.txt 


No comments:

Post a Comment