Expect script which can execute commands on multiple servers via SSH
This script will help Linux administrators in tasks where they need push commands on multiple servers in network. Script create SSH connection to every server located in hosts file, store fingerprint as trusted if needed, make "sudo su -" and push commands.
I am using it regularly when creating/deleting new users, patching applications or harvesting data.
There are some similar scripts on Internet but this one exceeds the functionality and usability of others.
First of all you must create file "hosts.list" (in same location as script) where you define servers which will use script for SSH connection. Each server on newline.
For example:
Script expect that you will use standard user account and then switch under root via "sudo su -". You will be asked for username and password when you start script.
After that will be executed commands specified in "execute commands" section.
Here is mentioned script:
I hope that script is clear. Every command must contain sign "\r" which means "Enter" and we are expecting $prompt which indicates the end of execution (timeout is 60 seconds).
Here is simple output:
Your input is only username and password.
I hope it will be useful!
- Pro psaní komentářů se přihlašte




