Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://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

TEST PROGRAM USING PUTTY 'PLINK' BELOW

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;
RUNNING WITH 'PLINK' GIVES:
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\test.pl line 24. ==============================
TEST PROGRAM USING OPENSSH 'SSH' BELOW
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;
RUNNING WITH OPENSSH 'SSH' COMMAND GIVES:
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\test.pl 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.

Thanks!

In reply to Help Required - Problem Automating SFTP by Kraythorne

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2024-03-28 10:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found