There are two ways..
a) Store actual password in text file (which is bit risky if someone got access to file, you are doomed)
b) Use ssh keys for automation and login - which what I recommend
c) Write a daemon / service and work in client / server environment to control all server. Requires network programming using perl / php /c /c++ etc. Difficult to maintain
Solution b is easy to use and implement:
First generate ssh key and upload to all your servers
Don't use su, use sudo w/o password to run commands
Write script to connect such as
Code:
#!/bin/bash
# some init
ssh -l username server1.com
sudo /path/to/command1
sudo /path/to/command2
# and you are done!
Run above script for all server or just add for loop and read all server names form an array.
Hope this helps!