in reply to Net::OpenSSH pass options to ssh

Hello zn553,

Welcome to the Monastery. You can find what you are looking for and much more here Re: SSHing in multiple servers and execute command on each.

Update: Minimal example with code see here: Re: Perl script works differently from Apache then CMD line.

Update2: Sample of code with multiple commands in one of the links that I provide you Re: Simple SSH based chat client:

my ($stop, $pid_stop) = $ssh->open2pty("sudo -k; sudo service ntp stop +") or die "open2pty failed: " . $ssh->error . "\n";

From the module documentation Net::OpenSSH/Net::OpenSSH methods:

($in, $out, $err, $pid) = $ssh->open_ex(\%opts, @cmd)

Hope this helps, BR.

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

Replies are listed 'Best First'.
Re^2: Net::OpenSSH pass options to ssh
by zn553 (Initiate) on Mar 18, 2019 at 15:26 UTC
    Hello my question is more related to pass several options to SSH using default_ssh_opts
      Net::OpenSSH constructor accepts two different sets of options to be passed to ssh: master_opts and default_ssh_opts.

      The first set goes into the ssh call that connects to the remote machine and creates the multiplexing socket.

      The second set goes into the ssh calls that are used to run the remote commands (when calling system or capture, for instance). They reuse the connection established by the master ssh process, and so at that point it is usually too late to set most of the options supported by ssh. In practice, using default_ssh_opts is very uncommon.

      Hello zn553,

      I was under the impression that you asked how to pass multiple commands, this is why I post my answer. Well fellow Monk salva has answered your question already :).

      BR / Thanos

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