visit
From the server send the file to each host using SCP and expect to avoid entering the password many times
#!/bin/bash
USER="user"
PASS="passwd"
DEST_PATH="/home/user"
list="192.168.0.1
192.168.0.2
192.168.0.3
192.168.0.4
192.168.0.5
192.168.0.6
"
for i in $list;
do
VAR=$(expect -c "
spawn scp -oStrictHostKeyChecking=no -oCheckHostIP=no file.txt $USER@$i:$DEST_PATH
match_max 100000
expect \"*?assword:*\"
send -- \"$PASS\r\"
send -- \"\r\"
expect eof
")
echo "$VAR" #to see remote command answer
done
From each host download the file from the server using rsync and expect to avoid entering the password many times
#!/bin/bash
USER="user"
PASS="passwd"
DEST_PATH="/home/user"
list="192.168.0.1
192.168.0.2
192.168.0.3
192.168.0.4
192.168.0.5
192.168.0.6
"
for i in $list;
do
VAR=$(expect -c "
spawn rsync -e \"ssh -o StrictHostKeyChecking=no\" file.txt $USER@$i:$DEST_PATH
match_max 100000
expect \"*?assword:*\"
send -- \"$PASS\r\"
send -- \"\r\"
expect eof
")
echo "$VAR"
done
Use the command parallel-scp to sent the file from the server to each host (hosts list on the ips.txt file one per line)
parallel-scp "-O StrictHostKeyChecking=no" --askpass -lremote_host_user -h ips.txt file.txt /remote/host/dest/path
#For files
base64 file_to_copy > file_to_recover
#For directories
base64 directory_to_copy.tar.gz > file_to_recover
#For RPMs
tar cfz - $(rpm -ql ssh) | base64 > file_to_recover
#For files
base64 -d file_to_recover
#For directories
base64 -d file_to_recover | tar xfz
#For RPM
base64 -d < file_to_recover | tar xfz -