PrimeLord has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks. This is my first post. I am having some problems with Net::SSH::Perl and I was hoping maybe some of you could help. I am trying to make a script work with RSA keys. Here is a an example of the test code I have tried so far.
use strict; use Net::SSH::Perl; my @key = ('identity_files', '/usr/home/username/.ssh/identity'); my $ssh = Net::SSH::Perl->new("host", @key); my $auth = Net::SSH::Perl::Auth->new('RSA', $ssh); print "Valid auth" if $auth->authenticate; my ($out, $err, $exit) = $ssh->cmd("uname -a"); print "$out\n";
I am getting an error message that says... Can't use string ("/usr/home/username/.ssh/identit") as an ARRAY ref while "strict refs" in use at /usr/local/lib/perl5/site_perl/5.005/Net/SSH/Perl/Auth/RSA.pm line 36, <GEN0> chunk 1. I have gone through the documentation several times trying to figure out what I am doing wrong, but I guess I am just not getting it. Can anyone show me where I am going wrong here? Also is there anyway to get the RSA keys to work with keys that have a pass phrase on them? Thanks for the help. Rick

Replies are listed 'Best First'.
Re: Net::SSH::Perl Question
by projekt21 (Friar) on Jan 15, 2002 at 00:02 UTC
    The documentation says:
    identity_files: (...) The value of this argument should be a reference to an array of strings, each string identifying the location of an identity file.

    So try:

    my $files = [ '/usr/home/username/.ssh/identity' ]; my $ssh = Net::SSH::Perl->new("host", "identity_files" => $files);

    alex pleiner <alex@zeitform.de>
    zeitform Internet Dienste

Re: Net::SSH::Perl Question
by dmmiller2k (Chaplain) on Jan 15, 2002 at 00:12 UTC

    I think the identity_files parameter takes an arrayref not a scalar:

    my $ssh = Net::SSH::Perl->new("host", identity_files => [ '/usr/home/username/ +.ssh/identity' ] );

    Update: whoops! Sorry, projekt21, I guess you beat me to it.

    dmm

    If you GIVE a man a fish you feed him for a day
    But,
    TEACH him to fish and you feed him for a lifetime
Re: Net::SSH::Perl Question
by runrig (Abbot) on Jan 15, 2002 at 01:24 UTC
    Net::SSH::Perl should be able to find that identity file by default anyway, but I believe you do need to login, even if there is no user or password:
    my $ssh = Net::SSH::Perl->new("host", @key); $ssh->login; my ($out, $err, $exit) = $ssh->cmd("uname -a");
    It looks like you are out of luck if you want a non-interactive session on a key that has a passphrase, though I have found that wrapping the above in a shell script like this works:
    ./my_ssh_script <<EOT passphrase EOT
    I haven't needed passphrases badly enough to inquire about a change (I just create the keys without passphrases), but reading the docs, it looks like the author (our own btrott) has thought about it, but hasn't gotten 'round 'tuit yet.
Re: Net::SSH::Perl Question
by Anonymous Monk on Nov 06, 2014 at 07:38 UTC
    i have the same code but it doesnt show output of command uname -a. it pending forever. please help me explain why it dont show output of command uname -a output like this: PC_PV: channel 1: new client-session PC_PV: Requesting channel_open for channel 1. PC_PV: Entering interactive session. PC_PV: Requesting service exec on channel 1. PC_PV: channel 1: open confirm rwindow 0 rmax 32768