Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

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
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 imbibing at the Monastery: (2)
As of 2020-08-04 02:48 GMT
Find Nodes?
    Voting Booth?
    Which rocket would you take to Mars?

    Results (31 votes). Check out past polls.