Michaels has asked for the wisdom of the Perl Monks concerning the following question:
Permission denied at /app/perl-5.24.3/lib/site_perl/5.24.3/Net/SFTP.pm line 63.
My connection code 'sftp_test2.pl':execution:use strict; use warnings; use Net::SFTP; my $server = 'downloads-server'; my $user = 'user'; my $port = "10022"; my $password = ''; my %args = ( user => "$user", password => '', port => "$port", ssh_args => { user => "$user", password => '', identity_files => [ 'path/sftp_download'], port => "$port", protocol=>'2,1', debug => 1, } ); my $sftp=Net::SFTP->new($server, %args) or die "could not open con +nection to $server\n";
I thought that it is related to my private key, but I can connect via unix command:$>perl sftp_test2.pl Reading configuration data path/home/.ssh/config Reading configuration data /etc/ssh_config Connecting to downloads-server, port 10022. Remote version string: SSH-2.0-CrushFTPSSHD Remote protocol version 2.0, remote software version CrushFTPSSHD Net::SSH::Perl Version 2.14, protocol version 2.0. No compat match: CrushFTPSSHD. Connection established. Sent key-exchange init (KEXINIT), waiting for response. Using diffie-hellman-group-exchange-sha256 for key exchange Host key algorithm: ssh-rsa Algorithms, c->s: aes256-ctr hmac-sha2-512-etm@openssh.com none Algorithms, s->c: aes256-ctr hmac-sha2-512-etm@openssh.com none Entering Diffie-Hellman Group Exchange. SSH2_MSG_KEX_DH_GEX_REQUEST(2048<4096<8192) sent Sent DH Group Exchange request, waiting for reply. Received 4096 bit DH Group Exchange reply. Generating new Diffie-Hellman keys. Entering Diffie-Hellman key exchange. Sent DH public key, waiting for reply. Received host key, type 'ssh-rsa'. Host 'downloads-server' is known and matches the host key. Verifying server signature. Send NEWKEYS. Waiting for NEWKEYS message. Enabling encryption/MAC/compression. Sending request for user-authentication service. Service accepted: ssh-userauth. Trying empty user-authentication request. Authentication methods that can continue: password,publickey,keybo +ard-interactive. Next method to try is password. Trying password authentication. Will not query passphrase in batch mode. Authentication methods that can continue: password,publickey,keybo +ard-interactive. Next method to try is password. Trying password authentication. Will not query passphrase in batch mode. Authentication methods that can continue: password,publickey,keybo +ard-interactive. Next method to try is password. Trying password authentication. Will not query passphrase in batch mode. Authentication methods that can continue: password,publickey,keybo +ard-interactive. Next method to try is password. Next method to try is publickey. Publickey: testing agent key 'my-server' Authentication methods that can continue: password,publickey,keybo +ard-interactive. Next method to try is password. Next method to try is publickey. Publickey: testing agent key 'path/home/.ssh/id_rsa' Authentication methods that can continue: password,publickey,keybo +ard-interactive. Next method to try is password. Next method to try is publickey. Trying pubkey authentication with key file 'path/sftp_download' Authentication methods that can continue: password,publickey,keybo +ard-interactive. Next method to try is password. Next method to try is publickey. Permission denied at /app/perl-5.24.3/lib/site_perl/5.24.3/Net/SFT +P.pm line 63.
I tried to find a solution in many articles and also tried few code variations, but without a success. I suspected that it may be related to multiple connection failing attempts with password so I removed the password authentication from "%AUTH_MAP" in the file "app/perl-5.24.3/lib/site_perl/5.24.3/x86_64-linux/Net/SSH/Perl/AuthMgr.pm" and it connected as expected!> sftp -oPort=10022 -oIdentityFile=path/sftp_download user@downloads-s +erver <br>Connecting to downloads-server... <br>sftp>
As I cannot edit Perl modules, I have to find other solution. Is there a way to force using only/first key authentication instead of password?
Thanks in advance! Mike
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: SFTP connection failure with Perl “Net::SFTP” module
by poj (Abbot) on May 06, 2019 at 09:27 UTC | |
by Michaels (Novice) on May 06, 2019 at 10:47 UTC | |
|
Re: SFTP connection failure with Perl “Net::SFTP” module
by thanos1983 (Parson) on May 06, 2019 at 08:16 UTC | |
by Michaels (Novice) on May 06, 2019 at 08:34 UTC | |
by thanos1983 (Parson) on May 06, 2019 at 09:15 UTC | |
by Michaels (Novice) on May 06, 2019 at 09:25 UTC | |
by thanos1983 (Parson) on May 06, 2019 at 09:42 UTC |