Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: SSHing in multiple servers and execute command on each

by thanos1983 (Parson)
on Jun 27, 2018 at 09:33 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-03-29 15:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found