Shell scripting to manage multiple servers at the same time, without the use of ansible, automatic manual implementation
SSH does not log on to the Machine execution command (if you have to implement password-free login)
ssh 127.0.0.1 ‘ifconfig‘ssh 127.0.0.1 ‘ifconfig|grep bbb‘ssh 127.0.0.1 ‘tail /var/log/secure‘
Shell while looping through the IP list of servers that need to be managed
cat /tmp/hosts|while read line;doecho $line;done
Combine these two implementations to manage multiple servers at the same time
- The first idea, but no way to manage multiple servers at the same time, can only manage 1 units
cat /tmp/hosts|while read line;doecho $linessh $line ‘tail /var/log/secure‘done
- A try to hit the log, or not
cat /tmp/hosts|while read line;doecho $linessh $line ‘tail /var/log/secure‘ >/tmp/${line}.logdone
Try to succeed, must be placed in the background &
cat /tmp/hosts|while read line;doecho $linessh $line ‘tail /var/log/secure‘ >/tmp/${line}.log &done
SSH no password, SCP is also no password.
Combined with the above, we have been able to manage multiple servers simultaneously, batch run commands, batch upload files, bulk download files.
Shell scripting implements managing multiple servers at the same time