I'm a bit beginner on linux. Let's imagine a scenario like this. I have 4 different linux machines and these 4 machines have different scripts. From to an another machine, I want to connect to these 4 different machines in the same script and run the scripts on this machines.
I created such a method in my head.
But I am not sure how to make ssh connection to 4 different machines at the same time. I think it should disconnect the ssh connection after it is done on one machine.
Do you think something like this will work or what can I do to make it work?
#!/bin/bash
variableA="$1"
SSHPASS='mypassforsshcon'
sshpass -p $SSHPASS ssh user@xxx.1 /home/admin/1.sh $variableA
sshpass -p $SSHPASS ssh user@xxx.2 /home/admin/2.sh $variableA
sshpass -p $SSHPASS ssh user@xxx.3 /home/admin/3.sh $variableA
sshpass -p $SSHPASS ssh user@xxx.4 /home/admin/4.sh $variableA
I would appreciate your help.