neversaint has asked for the wisdom of the Perl Monks concerning the following question:
What I usually do manually is to access "host1" via console's SSH, then do sftp from inside "host1" to "host2".__________ _________ | | | | My PC ------->| host1 |----------->| host2 | |________| |_______| user: myname usr: myname pswd: foo pswd: bar
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: $!";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Howto Access Two Consecutive Hosts with Net::SFTP
by salva (Canon) on Nov 14, 2005 at 13:00 UTC | |
|
Re: Howto Access Two Consecutive Hosts with Net::SFTP
by davidrw (Prior) on Nov 14, 2005 at 13:33 UTC | |
|
Re: Howto Access Two Consecutive Hosts with Net::SFTP
by Moron (Curate) on Nov 14, 2005 at 13:00 UTC | |
|
Re: Howto Access Two Consecutive Hosts with Net::SFTP
by marto (Cardinal) on Nov 14, 2005 at 12:22 UTC | |
by neversaint (Deacon) on Nov 14, 2005 at 14:13 UTC |