vatsal
vatsal

Reputation: 109

Interactive mode in Net::OpenSSH

I am a beginner in perl and trying to write a script that uses Net::OpenSSH to run commands on the given host. How do I do interactive mode auth in Net::OpenSSH similar to what we have in Net:SSH::Perl. Net:SSH::Perl has an interactive flag which takes in password if set to true otherwise public key auth. Following is the ssh object I have in Net::SSH::Perl which I would like to replicate in Net::OpenSSH :

 $ssh = Net::SSH::Perl->new($host,
                      debug          => $debug,
                      port           => $port,
                      interactive    => $imode,
                      identity_files => [ @keys ],
                      );

Also Net::SSH::Perl can take in an array of keys while Net::OpenSSH only one. How do I get around this?

Upvotes: 3

Views: 804

Answers (1)

salva
salva

Reputation: 10242

Net::OpenSSH already runs in interactive mode by default, letting the underlaying ssh process ask for a password when all the other authentication methods fail (you have to request batch_mode to disable it).

You can pass several keys through the master_opts constructor argument:

my $ssh = Net::OpenSSH->new($host, ...
                            master_opts => [map { -i => $_ } @keys]);

You can also create a feature request in the GitHub bug-tracker and I will eventually add support for accepting more than one key without using the master_opts hack.

Upvotes: 1

Related Questions