Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Efficient way of sending commands?
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Efficient way of sending commands?

Domin43Domin43 Member


What do you use to send commands to multiple servers at once?


  • SplitIceSplitIce Member, Host Rep

    use a bit of bash and pipe the commands to ssh?

  • gitresetgitreset Member
    edited June 2016

    Automatic or manual?

    If automatic:
    python + paramiko

    If manual:
    tmux, sync panes

    Thanked by 1Domin43
  • IshaqIshaq Member

    Or you can use something like SaltStack, or Ansible, and others to remotely manage and execute commands to your infrastructure.

    Thanked by 1Domin43
  • Well what's the best way you think. My current method is @SplitIce but needs to become easier because why not.

  • SplitIceSplitIce Member, Host Rep

    Just FYI, we use Ansible for deployment. Normally though you dont "execute commands" with it.

    You define a configuration state for each service a server has, then send to ansible for deployment. Or at-least thats how you should do it.

    Thanked by 1Domin43
  • raindog308raindog308 Administrator, Veteran
    edited June 2016

    SplitIce said: Just FYI, we use Ansible for deployment. Normally though you dont "execute commands" with it.


    Writing your own command executor isn't hard:

    while read host ; do
      ssh -i ${key} -p ${my_port} root@${host} ${some_command}
    done < /some/list/of/hosts.txt


    • you need to setup authorized_keys for that private key, of course
    • you should use prohibit-password (or "without-password") for PermitRootLogin in sshd_config
    • quoting in the above is a pain
    • stdout/stderr capturing is a pain

    You might consider scping a script and executing it, which avoids some of these problems.

    Thanked by 1Domin43
  • vfusevfuse Member, Host Rep

    RoyalTS or RoyalTSX has a broadcasting feature to send command to multiple servers.

    Thanked by 1raindog308
  • elgselgs Member

    I use pssh.

  • jtkjtk Member

    Unix-based command line tools such as pdsh or GNU parallel might be what you want.

  • ricardoricardo Member
    edited June 2016

    GNU parallel

    Was going to say that one.

    I'd SCP/rsync a bash script to each server like Raindog suggests (if its more than one or two commands) and then run the command. You can use exit codes from the bash script if you need an indication of what happened.

  • jarjar Patron Provider, Top Host, Veteran

    +1 for SaltStack. Super easy.

Sign In or Register to comment.