Live data from Hacker News

Show HN: Sshsync – CLI tool to run shell commands across multiple remote servers

github.com

71–77 of 77 posts

Re: Show HN: Sshsync – CLI tool to run shell commands across multiple remote servers

#71

Earlier quoted context omitted.

If it is already in place, then sure, why not. Not using what is already there would just be a waste, IMO.

I guess I don't understand why running a command in multiple places at once is preferable to running a shell script in four places in sequence. maybe it's me! there is approximately zero chance that running the same script on four of my machines would result in four cleanly run scripts. one or more would fail, and if more than one failed, they would each fail for a different reason.

You said Ansible and Puppet, they are not installed by default on any Linux distributions or BSDs that I know of.

I personally do not prefer "run command in multiple places at once" over "run command in four places in sequence", however. I think it would just be a "random" choice in my case, and I might just write a script that does either. I do not mind as long as it is a one-time thing, but if I would have to do this more than once, I would just automate it, via scripts. I would probably just have it run in sequence.

Re: Show HN: Sshsync – CLI tool to run shell commands across multiple remote servers

#72

In a past life, this is an interview question that I would ask people: "We have thousands of servers, and you need to run the same command on 10 of them, what's one way you would do it?" and follow up with "What if you wanted to run the command on hundreds or thousands - what problems would you expect with this approach, and what might you do differently?" I didn't really expect them to write code on the spot (hate t…

Are you still asking this question in an interview? I know a thing or two about sshing into servers, I think I'd be a good enough candidate

Unfortunately (or, fortunately) no - this was a lifetime ago when I owned a large hosting company

Re: Show HN: Sshsync – CLI tool to run shell commands across multiple remote servers

#73

I built (and still use) a similar tool called Overcast 10 years ago: https://github.com/andrewchilds/overcast

Dude, your tool does so much than just run ssh commands. I just took a quick glance at your project, just wanted to know does this have support for vultr?

It does not support Vultr currently, but it likely wouldn't be difficult to add. There's an open issue for it: https://github.com/andrewchilds/overcast/issues/58

Re: Show HN: Sshsync – CLI tool to run shell commands across multiple remote servers

#74

I built (and still use) a similar tool called Overcast 10 years ago: https://github.com/andrewchilds/overcast

Dude, your tool does so much than just run ssh commands. I just took a quick glance at your project, just wanted to know does this have support for vultr?

PR to add Vultr support: https://github.com/andrewchilds/overcast/pull/61

Re: Show HN: Sshsync – CLI tool to run shell commands across multiple remote servers

#75

I’m surprised no one has mentioned pdsh yet. Piped to dshbak and output was grouped by response. I’d probably use a config management tool for anything more than simple commands now but that tool was indispensable for managing our fleet, when we used to actually connect to machines.

Ditto. I posted (here: https://news.ycombinator.com/item?id=42881123 ) about them and other options:

To send the same command to multiple servers, use pdsh: https://linux.die.net/man/1/pdsh

To collect all the results and show which ones are the same or different, use dshbak (i.e., "pdsh |dshbak"): https://linux.die.net/man/1/dshbak

Similar things, sometimes more convenient but less efficient for a large number of servers, are to use the konsole terminal program and link multiple window tabs together so the same typed command goes to all, and quickly view the results across the tabs; or to use tmux and send the same commands to multiple windows (possible useful "man tmux" page terms: link-window, pipe-pane, related things to those, activity, focus, hooks, control mode).

And others that I haven't used but which also look possibly interesting for platforms where pdsh and dshbak might not be available (like OpenBSD at least):

- https://github.com/duncs/clusterssh/wiki (available on OpenBSD as a package)

- https://www.gnu.org/software/parallel/ (also available as a package on OpenBSD 7.6: named "parallel-20221122"; might relate to "pdksh")

- Also clusterit.

Re: Show HN: Sshsync – CLI tool to run shell commands across multiple remote servers

#76
post #60

Earlier quoted context omitted.

That's a great question you used in interviews! I'm curious – how would you personally approach this situation? What would your solution be for running a command on 10 servers, and how would you scale it to thousands?

For a handful of servers I would just do a for loop like `for i in {01..10};do echo "command" | ssh -T server$i.example.com;done` because it was quick and dirty and worked fine for something quick, but obviously it doesn't really ensure a common state or handle errors at all (but I still used a for loop like that many times a day for quick stuff like "I wonder what size a specific file is on each server" or "let me q…

thanks

Re: Show HN: Sshsync – CLI tool to run shell commands across multiple remote servers

#77

Earlier quoted context omitted.

Ansible is one of the best examples of needless complexity I’ve ever interacted with.

Ansible is the easiest tool for configuration management to onboard and start using. Great documentation, large community. It is as complex as you want it to be and it's complexity scales with your infra. ofc YMMV.

I disagree. It requires to know Python, YAML, Jinja2, own set of commands. It requires careful developing of playbooks. It is slow. It is complicated for non-standard cases where you don't have ready for using modules.

Is there a better approach? I think yes. This is Pyinfra - just pure Python, no additional DSLs. Also for configuration there is Terraform (but there are also some limitations).

Post reply on HN