Hello,
I'll try to make this short. I've successfully been able to connect to my SSH server using Net::SSH2. All is dandy, except I had some issues trying to run commands and gather the output. So that had me trying Net::SSH:Any using the SSH2 backend. I cannot connect as I receive an authentication error. I think I have pegged it to an issue with the publickey file.
Net::SSH2 code:$ssh2= Net::SSH2->new(); my $host = 'serveraddress'; my $port = 22; my $user = 'username'; $ssh2->connect($host, $port) or $ssh2->die_with_error; my $ppk_filepath = 'C:\Users\username\rsa-key-username'; print "$ppk_filepath exists!\n" if -e $ppk_filepath; $ssh2->auth_publickey($user, undef, $ppk_filepath, 'passphrase123' + ) or $ssh2->die_with_error;
This code works and I connect and can authenticate. But in fact, if I were to place my LOCAL publickey file path where undef currently is I would get authentication errors. I believe with undef it some how infers a .pub file from my private key. From SSH2.pm source:
"When libssh2 is compiled using OpenSSL as the crypto backend, passing this method C<undef> as the public key argument is acceptable (OpenSSL is able to extract the public key from the private one)."
use Net::SSH::Any; $Net::SSH::Any::debug = -1; my $host = 'serveraddress'; my $port = 22; my $user = 'username'; my $ppk_filepath = 'C:\Users\username\rsa-key-username'; $ssh2 = Net::SSH::Any->new($host, port => $port, user => $user, pa +ssphrase => 'passphrase123', key_path => $ppk_filepath, backends => ' +Net_SSH2'); if ($ssh2->error) { die "Connection error: " . $ssh2->error; }
Here I get an authentication error. I understand that it's looking for the .pub file, which I do have in the same directory as my privatekey file. Everything seems correct here. I've searched all over Google and Perl Monks for an answer and I appreciate all the info from Salva (that has helped me get Net::SSH2 up and running) but I cannot find too much about SSH::Any with SSH2 backend. Thanks for any help, from a beginnner.
In reply to Net::SSH::Any using SSH2 Backend and Public Key by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |