0

I'm using this command a lot to run a script on remote servers:

ssh root@servername.eu < ./remotescript.sh

It works quite well. Now that there are more servers I'm wondering how I could use a list of these servers with that command... like this for example:

ssh root@$server.list < ./remotescript.sh

What would be the easiest way to do this?

-Sam

SamTzu
  • 71

1 Answers1

1

if your file with hosts is something like:

server1
server2
server3

you can use code like:

while read host
do
ssh root@$host < ./remotescript.sh
done <server.list
Romeo Ninov
  • 17,484