Expect is usually the best tool to automate anything asking for a password at the tty. So what are the reasons you have to avoid it?
Net::OpenSSH::Parallel is a module that can be used to run commands in several hosts in parallel and it can be easily integrated with Expect to automate the sudo authentication steps. Look for sudo on the module documentation for an example.
Also, if the version of sudo installed on the remote machines is recent enough you may be able to pass the password directly through stdin. That is covered in Net::OpenSSH documentation. | [reply] [d/l] [select] |
Hello durgesh_p,
Why do you not want to use expect?
Do you have public key infraestructure handling ssh access to your account?
Not perl related, but you could consider see ansible
PD: I have a perl script to use 'ssh server "su - -c xxx"' , but it is using expect, it is called as_root
PD2: To run it on several machines I would use pdsh (still on code.google.com :( ) | [reply] |
There are risks associated with " Expect " with handing passwords...
Ansible is an option , but looking for a simple script based solution...
| [reply] |
All scripts which have a password inside will have the same problems that using Expect to introduce password, isn't it?.
I think it is better to use pki and passwordless specifics sudo commands
Regards
| [reply] |
| [reply] |
I am new to perl..still learning...not sure how to use these modules...
I am looking if someone has a existing script already...
| [reply] |
Most worthwhile CPAN modules have a sample script, or examples, or at least enough in the Synopsis to get you started.
Even if there were a magic script available it wouldn't be wise for you to use such a script if you didn't understand it. How would you know if it was safe to use?
Being new at Perl is the same as being new at everything else. You have to study, and learn, and practice, before you can successfully do it.
Your task is simple but not trivial. You should understand how to use modules, and you should start with a trivial task and simple modules. If you are bright it will take you about 1.5 days before you will be able to return to this task and use the more complicated modules to build your script. At that time you should begin by trying to connect to just one remote server before trying many simultaneous connections.
You might be able to find some shortcuts, but there is no time portal that will instantly transport you to understanding. You just have to do the work. Monks in this thread have pointed you in the right direction, now start reading!
The way forward always starts with a minimal test.
| [reply] [d/l] |