in reply to Re: get ssh key passphrase from agent
in thread get ssh key passphrase from agent

The Net:SSH:Perl:Agent module doesn't seem to work for me. I get the following error, even with the included sexample code.

Can't call method "identity_iterator" on an undefined value at .\sshtest.pl line 5.

This is the code I used:

#!/usr/bin/perl -w use Net::SSH::Perl; use Net::SSH::Perl::Agent; my $agent = Net::SSH::Perl::Agent->new(1); my $iter = $agent->identity_iterator; while (my($key, $comment) = $iter->()) { print $key; }

I think this means, that $agent is not defined, so Net::SSH::Perl::Agent->new didn't work. My ssh agent works fine in my shell directly with the ssh command tho.

Please Let me know what I might be doing wrong.

Thanks, Ninto!

Replies are listed 'Best First'.
Re^3: get ssh key passphrase from agent
by choroba (Cardinal) on Aug 31, 2022 at 07:24 UTC
    I don't get any error, but the script you posted doesn't output anything unless I change the version of the agent to 2.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

      I still get the same error, even if I change it.

      Could you please elaborate furhter, what you did to make it work?

        I replaced
        my $agent = Net::SSH::Perl::Agent->new(1); # ~
        with
        my $agent = Net::SSH::Perl::Agent->new(2); # ~

        map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]