in reply to Re^7: transfer a file via SFTP
in thread transfer a file via SFTP
cc:/sftp/test# # cat test_sftp.cgi #!/usr/bin/perl -w use strict; use warnings; use Net::SFTP; my $file = 'TEST.txt'; my $server = 'X.X.X.X'; my $user = 'user'; my $sftp; my %args = ( ssh_args => { user => 'user', identity_files => [ '/root/.ssh/id_r +sa' ], debug => 1 } ); $sftp = Net::SFTP->new($server, %args) or die "could not open connection to $server\n"; $sftp->put($file, $file) or die "could not upload $file\n"; exit;
works and send a file without any problems, but if change this script to:cc:/sftp/test# perl test_sftp.cgi cc: Reading configuration data /root/.ssh/config cc: Reading configuration data /etc/ssh_config cc: Allocated local port 1023. cc: Connecting to X.X.X.X, port 22. cc: Remote protocol version 2.0, remote software version 4.0.7.1 SSH S +ecure Shell Windows NT Server cc: Net::SSH::Perl Version 1.34, protocol version 2.0. .inux.ch.bluee.net: No compat match: 4.0.7.1 SSH Secure Shell Windows +NT Server cc: Connection established. cc: Sent key-exchange init (KEXINIT), wait response. cc: Algorithms, c->s: 3des-cbc hmac-sha1 none cc: Algorithms, s->c: 3des-cbc hmac-sha1 none cc: Entering Diffie-Hellman Group 1 key exchange. cc: Sent DH public key, waiting for reply. cc: Received host key, type 'ssh-dss'. cc: Host 'X.X.X.X' is known and matches the host key. cc: Computing shared secret key. cc: Verifying server signature. cc: Waiting for NEWKEYS message. cc: Send NEWKEYS. cc: Enabling encryption/MAC/compression. cc: Sending request for user-authentication service. cc: Service accepted: ssh-userauth. cc: Trying empty user-authentication request. cc: Authentication methods that can continue: gssapi,publickey,passwor +d. cc: Next method to try is publickey. cc: Trying pubkey authentication with key file '/root/.ssh/id_rsa' cc: Login completed, opening dummy shell channel. cc: channel 0: new [client-session] cc: Requesting channel_open for channel 0. cc: channel 0: open confirm rwindow 100000 rmax 16384 cc: channel 1: new [client-session] cc: Requesting channel_open for channel 1. cc: Sending subsystem: sftp cc: Requesting service subsystem on channel 1. cc: channel 1: open confirm rwindow 100000 rmax 16384
then cannot send due to the following problem:my $file = '/sftp/test/TEST.txt';
In both cases the file is in the same directory where the script is and the path is 100% correct................................................................ ............................................................... ............................................................... cc: Sending subsystem: sftp cc: Requesting service subsystem on channel 1. cc: channel 1: open confirm rwindow 100000 rmax 16384 Couldn't get handle: Permission denied at test_sftp.cgi line 21 could not upload /sftp/test/TEST.txt
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^9: transfer a file via SFTP
by ig (Vicar) on Jul 29, 2009 at 19:34 UTC | |
by cc (Beadle) on Jul 30, 2009 at 11:52 UTC | |
by ig (Vicar) on Jul 30, 2009 at 18:40 UTC | |
by cc (Beadle) on Jul 30, 2009 at 21:27 UTC | |
by ig (Vicar) on Jul 31, 2009 at 21:32 UTC | |
|