1

I have been using the SSH package of Perl to connect to my RHEL systems. I recently upgraded one of my VM to redhat-release-server-7.2-9.el7.x86_64. Now when I am running my Perl script it is throwing the error:

Can't locate object method "exchange" via package "Net::SSH::Perl::Kex::C25519" at /usr/local/lib64/perl5/Net/SSH/Perl/Kex.pm line 107. when making the ssh object.

The same script is otherwise working on my 6.8 RHEL version. Any suggestions?

Here is the code:

#!/usr/local/bin/perl
use strict;
use warnings;
use Net::SSH::Perl;
my $ssh = Net::SSH::Perl->new($server_ip, debug=>1);
$ssh->login("root","password");

Debug print:

[root@Automation_linux_10]# perl temp.pl
Automation_linux_[Auto_server_ip]: Reading configuration data /root/.ssh/config
Automation_linux_[Auto_server_ip]: Reading configuration data /etc/ssh_config
Automation_linux_[Auto_server_ip]: Allocated local port 1023.
Automation_linux_[Auto_server_ip]: Connecting to [SERVER_IP], port 22.
Automation_linux_[Auto_server_ip]: Remote version string: SSH-2.0-OpenSSH_6.6.1
Automation_linux_[Auto_server_ip]: Remote protocol version 2.0, remote software version OpenSSH_6.6.1
Automation_linux_[Auto_server_ip]: Net::SSH::Perl Version 2.12, protocol version 2.0.
Automation_linux_[Auto_server_ip]: No compat match: OpenSSH_6.6.1.
Automation_linux_[Auto_server_ip]: Connection established.
Automation_linux_[Auto_server_ip]: Sent key-exchange init (KEXINIT), waiting for response.
Automation_linux_[Auto_server_ip]: Using curve25519-sha256@libssh.org for key exchange
Automation_linux_[Auto_server_ip]: Host key algorithm: ssh-ed25519
Automation_linux_[Auto_server_ip]: Algorithms, c->s: chacha20-poly1305@openssh.com <implicit> none
Automation_linux_[Auto_server_ip]: Algorithms, s->c: chacha20-poly1305@openssh.com <implicit> none
Can't locate object method "exchange" via package "Net::SSH::Perl::Kex::C25519" at /usr/local/lib64/perl5/Net/SSH/Perl/Kex.pm line 107.
aristotll
  • 8,694
  • 6
  • 33
  • 53
Ankit Sinha
  • 33
  • 1
  • 5
  • We need to see some code. And it would be useful to see the versions of the modules which are installed on the two systems. – Dave Cross Aug 17 '17 at 09:15
  • Thanks for responding Dave. I have added both the code and the debug prints. – Ankit Sinha Aug 17 '17 at 09:41
  • https://stackoverflow.com/questions/5031334/perls-netssh-vs-ssh2-vs-openssh-how-should-i-compare-them if you decide to switch. – mpapec Aug 17 '17 at 11:16
  • @Сухой27 I tried OpenSSH and that is working fine. Since I don't think I would be getting a solution to my problem anytime soon I would probably go with OpenSSH only. However, I have more scripts which are using Net::SSH and using two packages for same work doesn't sound good to me. Either I change the other scripts too... but before that will try to get in touch with the developer of the package to see if there is some solution. – Ankit Sinha Aug 18 '17 at 01:33

1 Answers1

1

My guess is that you don't have the Crypt::Curve25519 perl module installed.

What I did to discover this was modify Kex.pm from the Net::SSH::Perl package like this:

--- lib/perl5/vendor_perl/5.26.0/i386-netbsd-thread-multi/Net/SSH/Perl/Kex.pm.orig      2017-08-23 11:10:46.000000000 +0000
+++ lib/perl5/vendor_perl/5.26.0/i386-netbsd-thread-multi/Net/SSH/Perl/Kex.pm
@@ -234,6 +234,9 @@ sub choose_kex {
     if (my $pkg = $kexmap{$name}) {
         $kex->{ssh}->debug("Using $name for key exchange");
         eval "use Net::SSH::Perl::Kex::$pkg";
+        if ($@) {
+            $kex->{ssh}->debug("Problem using Net::SSH::Perl::Kex::$pkg: $@");
+        }
         $kex->{class_name} = __PACKAGE__ . '::' . $pkg;
     } else {
         croak "Bad kex algorithm $name";

and used the small test script above to get a voluminous error message that the above mentioned perl module wasn't found.

S. Matsepura
  • 1,673
  • 1
  • 17
  • 24