Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: get ssh key passphrase from agent

by atcroft (Abbot)
on Aug 30, 2022 at 23:39 UTC ( [id://11146524]=note: print w/replies, xml ) Need Help??


in reply to get ssh key passphrase from agent

Poking around in Net::SSH::Perl and its components, a couple of things suggested themselves to me. First was Net::SSH::Perl::Key->read_private($key_type, $file [, $pass] ) that can read and decrypt a private key using $pass. That with Net::SSH::Perl::Util->_read_passphrase($prompt) might be an approach. While looking at Net::SSH::Perl::Util, though, there was also Net::SSH::Perl::Util->_load_private_key($key_file [, $passphrase]). There is also Net::SSH::Perl::Agent, which indicates it can interact as a client for agent-based publickey authentication.

I know how much "fun" it can be dealing with SSH, so I hope some of the above is helpful.

Replies are listed 'Best First'.
Re^2: get ssh key passphrase from agent
by ninto1 (Novice) on Aug 31, 2022 at 06:05 UTC

    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!

      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?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2024-04-20 05:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found