Subject: | Autoinstallation won't work with CPANPLUS and sudo. |
Net::SSH::Perl attempts to do its own dependency resolution using the CPAN shell. This makes it fail to install if you're installing it using CPANPLUS and don't have the CPAN shell properly configured.
Additionally, because CPANPLUS provides the option to run "perl Makefile.PL" and "make" as a normal user and only switch to root for the actual process of installation, Net::SSH::Perl will run the CPAN shell as a normal user. It needs to be run as root.
Net::SSH::Perl does ask you per module if you'd like the dependency resolved but its not clear that they will still be put into PREREQ_PM and handled by CPANPLUS. Additionally, there is no way to tell it to not immediately install the optional modules yet still list them in your PREREQ_PM so CPANPLUS handles them.
Because of this I would recommend removing the custom autoinstall code. If you want autoinstall you'll use the CPAN or CPANPLUS shell directly. If you're not already using the CPAN shell the autoinstall won't work very well since the CPAN shell won't be configured.