NAME
Net::SFTP - Secure File Transfer Protocol client
SYNOPSIS
use Net::SFTP;
my $sftp = Net::SFTP->new($host);
$sftp->get("foo", "bar");
$sftp->put("bar", "baz");
DESCRIPTION
Net::SFTP is a pure-Perl implementation of the Secure File Transfer Protocol (SFTP)--file transfer built on top of the SSH protocol. Net::SFTP uses Net::SSH::Perl to build a secure, encrypted tunnel through which files can be transferred and managed. It provides a subset of the commands listed in the SSH File Transfer Protocol IETF draft, which can be found at http://www.openssh.com/txt/draft-ietf-secsh-filexfer-00.txt.
SFTP stands for Secure File Transfer Protocol and is a method of transferring files between machines over a secure, encrypted connection (as opposed to regular FTP, which functions over an insecure connection). The security in SFTP comes through its integration with SSH, which provides an encrypted transport layer over which the SFTP commands are executed, and over which files can be transferred. The SFTP protocol defines a client and a server; only the client, not the server, is implemented in Net::SFTP.
Because it is built upon SSH, SFTP inherits all of the built-in functionality provided by Net::SSH::Perl: encrypted communications between client and server, multiple supported authentication methods (eg. password, public key, etc.).
USAGE
Net::SFTP->new($host, %args)
Opens a new SFTP connection with a remote host $host, and returns a Net::SFTP object representing that open connection.
%args can contain:
user
The username to use to log in to the remote server. This should be your SSH login, and can be empty, in which case the username is drawn from the user executing the process.
See the login method in Net::SSH::Perl for more details.
password
The password to use to log in to the remote server. This should be your SSH password, if you use password authentication in SSH; if you use public key authentication, this argument is unused.
See the login method in Net::SSH::Perl for more details.
debug
If set to a true value, debugging messages will be printed out for both the SSH and SFTP protocols. This automatically turns on the debug parameter in Net::SSH::Perl.
The default is false.
ssh_args
Specifies a reference to a list of named arguments that should be given to the constructor of the Net::SSH::Perl object underlying the Net::SFTP connection.
For example, you could use this to set up your authentication identity files, to set a specific cipher for encryption, etc.
See the new method in Net::SSH::Perl for more details.
$sftp->get($remote [, $local ])
Downloads a file $remote from the remote host. If $local is specified, it is opened/created, and the contents of the remote file $remote are written to $local. In addition, its filesystem attributes (atime, mtime, permissions, etc.) will be set to those of the remote file.
If $local is not given, returns the contents of $remote.
$sftp->put($local, $remote)
Uploads a file $local from the local host to the remote host, and saves it as $remote.
$sftp->ls($remote [, $subref ])
Fetches a directory listing of $remote.
If $subref is specified, for each entry in the directory, $subref will be called and given a reference to a hash with three keys: filename, the name of the entry in the directory listing; longname, an entry in a "long" listing like ls -l
; and a, a Net::SFTP::Attributes object, which contains the file attributes of the entry (atime, mtime, permissions, etc.).
If $subref is not specified, returns a list of directory entries, each of which is a reference to a hash as described in the previous paragraph.
AUTHOR & COPYRIGHTS
Benjamin Trott, ben@rhumba.pair.com
Except where otherwise noted, Net::SFTP is Copyright 2001 Benjamin Trott. All rights reserved. Net::SFTP is free software; you may redistribute it and/or modify it under the same terms as Perl itself.