Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
OK, I guess you could call me an 'Intermediate Perl User' - not an expert by any stretch.

I'm trying to automate SFTP polling and donwnloading from one of our clients' site but have hit a stumbling block. Here's what I'm doing (using a windows xp OS):

The client has generated the secure encrypted key.
Installed openssh
Installed Putty
sshd service is running


use strict; use warnings; use Net::SFTP::Foreign; my $host = '*mycompany*@*client_ftp_IP*'; my %args = ('ssh_cmd' => 'C:\Program Files\PuTTY\plink', ); my $sftp = Net::SFTP::Foreign->new( $host, %args, more => [ -P => '*connection port*', -i => 'G:\FTP\id_cmf_mediatechid_cmf_mediatech.ppk', -ssh, '-v', ] ); $sftp->error and die "Unable to stablish SFTP connection: " . sftp->error; $sftp->get("foo", "bar") or die "get failed: " . sftp->error; $sftp->put("bar", "baz") or die "put failed: " . sftp->error;
Looking up host "*client_ftp_IP*" Connecting to *client_ftp_IP* port *connection port* Server version: SSH-2.0-OpenSSH_5.1 We claim version: SSH-2.0-PuTTY_Release_0.60 Using SSH protocol version 2 Doing Diffie-Hellman group exchange Doing Diffie-Hellman key exchange with hash SHA-256 Host key fingerprint is: ssh-rsa 2048 *FINGERPRINT KEY* Initialised AES-256 SDCTR client->server encryption Initialised HMAC-SHA1 client->server MAC algorithm Initialised AES-256 SDCTR server->client encryption Initialised HMAC-SHA1 server->client MAC algorithm Reading private key file "G:\FTP\id_cmf_mediatech\id_cmf_mediatech.ppk +" Using username "mycompany". Offered public key Offer of public key accepted Authenticating with public key "rsa-key-20081029" Access granted Opened channel for session Server refused to start a shell/command FATAL ERROR: Server refused to start a shell/command Unable to stablish SFTP connection: Connection to remote server is bro +ken at C:\PROGRA~1\OpenSSH\usr\sbin\ line 24. ==============================
use strict; use warnings; use Net::SFTP::Foreign; my $host = '*mycompany*@*client_ftp_IP*'; my %args = ('ssh_cmd' => 'C:\Program Files\OpenSSH\bin\ssh', ); my $sftp = Net::SFTP::Foreign->new( $host, %args, more => [ -p => '*connection port*', -i => 'C:\Documents and Settings\.ssh\id_cmf_mediatech', '-v', ] ); $sftp->error and die "Unable to stablish SFTP connection: " . $sftp->error;
OpenSSH_3.8.1p1, OpenSSL 0.9.7d 17 Mar 2004 debug1: Reading configuration data /etc/ssh_config debug1: Connecting to *client_ftp_IP* [*client_ftp_IP*] port <connecti +on port>. debug1: Connection established. debug1: identity file C:\\Documents and Settings\\.ssh\\id_cmf_mediate +ch type -1 debug1: Remote protocol version 2.0, remote software version OpenSSH_5 +.1 debug1: match: OpenSSH_5.1 pat OpenSSH* debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_3.8.1p1 debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client aes128-cbc hmac-md5 none debug1: kex: client->server aes128-cbc 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: Host '<client_ftp_IP>' is known and matches the RSA host key. debug1: Found key in /home/.ssh/known_hosts:1 debug1: ssh_rsa_verify: signature correct debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: SSH2_MSG_SERVICE_REQUEST sent debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey,gssapi-with-mic,p +assword debug1: Next authentication method: publickey debug1: Trying private key: C:\\Documents and Settings\\.ssh\\id_cmf_m +ediatech debug1: read PEM private key done: type RSA debug1: Authentication succeeded (publickey). debug1: channel 0: new [client-session] debug1: Entering interactive session. debug1: Sending subsystem: sftp Request for subsystem 'sftp' failed on channel 0 Unable to stablish SFTP connection: Connection to remote server is bro +ken at C:\ PROGRA~1\OpenSSH\usr\sbin\ line 23.

I'm trying to figure out why this is falling down but the Putty and OpenSSH help is vague and other than checking that the Subsystem path in the sshd_config for OpenSSH is correct, I'm stuck!

If anyone can help suggest how I can either fix this, or an alternative method of initiating sftp which I can automate through Perl, I would greatly appreciate it.


In reply to Help Required - Problem Automating SFTP by Kraythorne

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others contemplating the Monastery: (7)
    As of 2021-04-21 07:48 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found