Changes in multiple machines at a time through scripting..!

Hello TecMint,

I have small question…
If i have five diff machines… like
10.0.0.1
10.0.0.2
10.0.0.3
10.0.0.4
10.0.0.5

How to set the host names for all machines at a time and password less SSH too.

Thanks,

Write those in a file (name it list.txt for example) , keep them in the same format as you have listed them. Then run the following:

for i in $(cat list.txt); do ssh user@$i command; done

Here is an example:

for i in $(cat list.txt); do ssh root@$i ‘free -m’ > /tmp/memory.status; done

Give any additional parameters to the SSH if you are using different SSH port or RSA DSA keys.

2 Likes

I think you should have a look at PSSH [https://code.google.com/p/parallel-ssh/][1]

PSSH allows you to execute the scirpt on multiple machines in the network.
[1]: https://code.google.com/p/parallel-ssh/