How about using scp
in a for
loop?
for server in user1@server1 user2@server2 user3@server3
do
scp /storage1/data/client "$server":/usr/bin/
done
If the servers are already in an array, you would use:
#!/bin/bash
for server in "${servers[@]}"
do
scp /storage1/data/client "$server":/usr/bin/
done
If in a file (single server per line), you would write:
while IFS= read -r server
do
scp /storage1/data/client "$server":/usr/bin/
done < serverfile
Of course you can manually add the root
user if that is user you want to connect with (this also strips leading and trailing whitespace), like so:
while read server
do
scp /storage1/data/client root@"$server":/usr/bin/
done < serverfile
If the number of servers is too large you could do the copying concurrently, like so:
for server in user1@server1 user2@server2 user3@server3
do
scp /storage1/data/client "$server":/usr/bin/ &
done
wait