Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: SSHing in multiple servers and execute command on each

by thanos1983 (Parson)
on Jun 27, 2018 at 09:33 UTC ( #1217493=note: print w/replies, xml ) Need Help??

in reply to SSHing in multiple servers and execute command on each

Hello sabas,

I had a similar case some time ago and I created multiple scenarios and solutions to my problem. My way of approaching your problem would be:

Net::OpenSSH::Parallel already Anonymous Monk proposed it. Alternatively you can create a foreach loop to connect to all nodes one by one. I would not use password authentication if I was you I would use ssh key authentication (more secure). The approach of looping one by one to the nodes I do not recommend it as it can result in time consuming and also if one node for some reason can not be reached can block the rest of the queue.

Sample of code for Net::OpenSSH::Parallel can be found here Re: multiple machines disk space alert. Sample of code using foreach loop and Net::OpenSSH can be found here Re: Simple SSH based chat client.

Hope this helps. BR / Thanos

Seeking for Perl wisdom...on the process of learning...not there...yet!

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1217493]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2023-02-07 07:49 GMT
Find Nodes?
    Voting Booth?
    I prefer not to run the latest version of Perl because:

    Results (38 votes). Check out past polls.