Dear Masters,
I have the following problem. Here I want to get/put files
from my PC at home into "host2" at any specified path. The problem is "host2" can
only be accessed via "host1".
__________ _________
| | | |
My PC ------->| host1 |----------->| host2 |
|________| |_______|
user: myname usr: myname
pswd: foo pswd: bar
What I usually do manually is to access "host1" via console's SSH, then do sftp from inside "host1" to "host2".
Is there a way to do it automatically with Net::SFTP? Cause the following code I have only allowed me to access "host1".
use Net::SFTP;
use Net::SSH::Perl;
my $host1 = 'host1';
my $pass1 = 'foo'; # password for host1
my $path1 = '/somepath'; # not really necessary
my $host2 = 'host2';
my $pass2 = 'bar'; # password for host1
my $path2 = '/somepath2'; # the actual path which I want to access
my $user = 'myname'; # username for host1 and host2 are the same
my $home = 'mycode.pl';
my $sftp = Net::SFTP->new($host1, "user" => $user,
"password" => $pass1,
"debug"=>1)
|| die 'cannot login $!\n';
$sftp->put($home,$path1)|| die "cannot open: $!";
---
neversaint and everlastingly indebted.......
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, details, 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, summary, 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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.