LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Trouble scripting SFTP transfer. (https://www.linuxquestions.org/questions/programming-9/trouble-scripting-sftp-transfer-911121/)

giantanakim 10-31-2011 02:36 PM

Trouble scripting SFTP transfer.
 
Hi everyone: I am running into a wall with this one. I have developed a bash script to upload wav files to an sftp server. Here is what I have developed so far:

Code:

#!/usr/bin/perl -w
use Net::SFTP::Foreign;
#use strict;
use warnings;
my $host = "12.12.12.12";
my %args = (
        user => 'upload',
        password => 'wavs',
        );
my $sftp = Net::SFTP::Foreign->new($host, %args, more => '-v');
$sftp->mkdir ("/test");
$sftp->put ("~/Documents/testftp.txt", "/test/testftp.txt");

Here is what I get from the verbose mode:

OpenSSH_5.8p1 Debian-7ubuntu1, OpenSSL 1.0.0e 6 Sep 2011
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 12.12.12.12 [12.12.12.12] port 22.
debug1: Connection established.
debug1: identity file /home/user/.ssh/id_rsa type -1
debug1: identity file /home/user/.ssh/id_rsa-cert type -1
debug1: identity file /home/user/.ssh/id_dsa type -1
debug1: identity file /home/user/.ssh/id_dsa-cert type -1
debug1: identity file /home/user/.ssh/id_ecdsa type -1
debug1: identity file /home/user/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.5p1 Debian-6
debug1: match: OpenSSH_5.5p1 Debian-6 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.8p1 Debian-7ubuntu1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx


After I receive that, it goes back to the standard command prompt. When I try to verify transfer by connecting via a Filezilla, nothing has been created or transferred. Any tips as to what I am missing?

unSpawn 10-31-2011 05:36 PM

Can't you use snailbook's I want to use sftp in a script nfo instead? Explains all and w/o needing Perl modules. If you however would like to pursue your approach what does the server side SSH daemon log say?

giantanakim 11-07-2011 01:05 PM

Thanks for your help. I was actually able to figure out what was causing the issue. For some reason the script was not accepting the server assigned key. Once I logged in manually through the terminal and accepted the key, everything is now working properly.

Thanks again.


All times are GMT -5. The time now is 03:35 AM.