Search code examples
linuxunixoracle-sqldeveloperpuppetremote-server

Run a command in remote server


What would be the best way to run commands in remote servers? I am thinking of using SSH, but is there a better way than that? I used Red Hat Linux and I want to run the command in one of the servers, specify what other servers I want to have my command run, and it has to do the exact same thing in the servers specified. Puppet couldn't solely help, but I might be able to combine some other tool with Puppet to do the job for me.


Solution

  • It seems you are able to log on to the other servers without entering a password. I assume this is based on SSH keys, as described here: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/s2-ssh-configuration-keypairs.html

    You say another script is producing a list of servers. You can now use the following simple script to loop over the list:

    for server in `./server-list-script`; do
      echo $server:
      ssh username@$server mkdir /etc/dir/test123
    done >logfile 2>&1
    

    The file "logfile" will collect the output. I'm pretty sure Puppet is able to do this as well.