scp a single file to multiple locations

Solution 1:

Let's say you have a file (destfile.txt) with user@host-values, one on each line. Then you could do like this:

while IFS= read -r dest; do
  scp ourfile.txt "$dest:remote/path/"
done <destfile.txt

Solution 2:

Looks like a job for parallel-scp(n)(t) - this implements a set of commands that allow for scp commands to be run on multiple systems at once. It will allow for the copying of files in parallel to a set of machines.

Solution 3:

cat file.txt | tee >(ssh [email protected] "cat > file.txt") \
                   >(ssh [email protected] "cat > file.txt")

tar cz file1 file2 file3 | tee >(ssh [email protected] "tar xz") \
                               >( ... )

Solution 4:

If you have a consistent naming convention going on for multiple servers, you can do something neat like:

for x in st1-abc-{11..20}.acme.com; do scp filez.tgz user@$x; done