Bootstrap FreeKB - Perl (Scripting) - Getting Started with Net::SFTP
Perl (Scripting) - Getting Started with Net::SFTP

Updated:   |  Perl (Scripting) articles

Before using the Perl SFTP module, you may want to use the ftp command (Linux) to determine if you are able to connect and authenticate onto the target FTP server.

This assumes you have installed the Net::SFTP module on your Perl system. Following is the most simple example of how to GET or PUT using the SFTP module.


use strict;
use warnings;
use Net::SFTP;

my $host        = "your_hostname";
my %args        = ();
$args{user}     = "your_username";
$args{password} = "your_password";
$args{debug}    = "true";

my $sftp = Net::SFTP->new($host, %args);

$sftp->get("/path/to/remote/foo.txt", "/path/to/local/foo.txt");
$sftp->put("/path/to/local/foo.txt", "/path/to/remote/foo.txt");


Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee


Add a Comment

Please enter 730532 in the box below so that we can be sure you are a human.