The ssh logs from your server should be very helpful in determining why permission is denied.
You have generated an RSA key but Net::SSH::Perl, on which Net::SFTP is based, uses DSA by default. By default it appears to ignore RSA keys. The version I have also ignores ~/.ssh/identity, despite the documentation that this is one of the default identity files. Therefore, it appears necessary to specify an RSA identity file explicitly.
I have done this with the following configuration:
my %args = (ssh_args => { identity_files => [ "/home/username/.ssh/id_ +rsa" ], } ); $args{debug} = 1; $args{user} = "username";
With the identity_files argument to Net::SSH::Perl specified, as above, the id_rsa file was read and authentication completed successfully.
Alternatively, you can create a DSA identity file with ssh-keygen -t dsa. Net::SSH::Perl will use a DSA key named $ENV{HOME}/.ssh/id_dsa by default.
In reply to Re^3: transfer a file via SFTP
by ig
in thread transfer a file via SFTP
by cc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |