-.\" $OpenBSD: sftp.1,v 1.58 2004/10/07 10:10:24 djm Exp $
+.\" $OpenBSD: sftp.1,v 1.80 2010/01/09 23:04:13 dtucker Exp $
.\"
.\" Copyright (c) 2001 Damien Miller. All rights reserved.
.\"
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd February 4, 2001
+.Dd $Mdocdate$
.Dt SFTP 1
.Os
.Sh NAME
.Sh SYNOPSIS
.Nm sftp
.Bk -words
-.Op Fl 1Cv
+.Op Fl 1246Cpqrv
.Op Fl B Ar buffer_size
.Op Fl b Ar batchfile
+.Op Fl c Ar cipher
+.Op Fl D Ar sftp_server_path
.Op Fl F Ar ssh_config
+.Op Fl i Ar identity_file
.Op Fl o Ar ssh_option
-.Op Fl P Ar sftp_server_path
+.Op Fl P Ar port
.Op Fl R Ar num_requests
.Op Fl S Ar program
.Op Fl s Ar subsystem | sftp_server
.Ar host
.Ek
.Nm sftp
-.Oo Oo Ar user Ns @ Oc Ns
-.Ar host Ns Oo : Ns Ar file Oo
-.Ar file Oc Oc Oc
+.Oo Ar user Ns @ Oc Ns
+.Ar host Ns Op : Ns Ar
.Nm sftp
-.Oo Oo Ar user Ns @ Oc Ns
+.Oo Ar user Ns @ Oc Ns
.Ar host Ns Oo : Ns Ar dir Ns
-.Oo Ar / Oc Oc Oc
+.Op Ar / Oc
.Nm sftp
.Fl b Ar batchfile
.Oo Ar user Ns @ Oc Ns Ar host
authentication method is used; otherwise it will do so after
successful interactive authentication.
.Pp
-The third usage format allows the sftp client to start in a remote directory.
+The third usage format allows
+.Nm
+to start in a remote directory.
.Pp
The final usage format allows for automated sessions using the
.Fl b
option.
-In such cases, it is usually necessary to configure public key authentication
+In such cases, it is necessary to configure non-interactive authentication
to obviate the need to enter a password at connection time (see
.Xr sshd 8
and
.Bl -tag -width Ds
.It Fl 1
Specify the use of protocol version 1.
+.It Fl 2
+Specify the use of protocol version 2.
+.It Fl 4
+Forces
+.Nm
+to use IPv4 addresses only.
+.It Fl 6
+Forces
+.Nm
+to use IPv6 addresses only.
.It Fl B Ar buffer_size
Specify the size of the buffer that
.Nm
commands fail:
.Ic get , put , rename , ln ,
.Ic rm , mkdir , chdir , ls ,
-.Ic lchdir , chmod , chown , chgrp , lpwd
+.Ic lchdir , chmod , chown ,
+.Ic chgrp , lpwd , df ,
and
.Ic lmkdir .
Termination on error can be suppressed on a command by command basis by
Enables compression (via ssh's
.Fl C
flag).
+.It Fl c Ar cipher
+Selects the cipher to use for encrypting the data transfers.
+This option is directly passed to
+.Xr ssh 1 .
+.It Fl D Ar sftp_server_path
+Connect directly to a local sftp server
+(rather than via
+.Xr ssh 1 ) .
+This option may be useful in debugging the client and server.
.It Fl F Ar ssh_config
Specifies an alternative
per-user configuration file for
.Xr ssh 1 .
This option is directly passed to
.Xr ssh 1 .
+.It Fl i Ar identity_file
+Selects the file from which the identity (private key) for public key
+authentication is read.
+This option is directly passed to
+.Xr ssh 1 .
.It Fl o Ar ssh_option
Can be used to pass options to
.Nm ssh
.It GlobalKnownHostsFile
.It GSSAPIAuthentication
.It GSSAPIDelegateCredentials
+.It HashKnownHosts
.It Host
.It HostbasedAuthentication
.It HostKeyAlgorithms
.It Protocol
.It ProxyCommand
.It PubkeyAuthentication
+.It RekeyLimit
.It RhostsRSAAuthentication
.It RSAAuthentication
.It SendEnv
.It UserKnownHostsFile
.It VerifyHostKeyDNS
.El
-.It Fl P Ar sftp_server_path
-Connect directly to a local sftp server
-(rather than via
-.Xr ssh 1 )
-This option may be useful in debugging the client and server.
+.It Fl P Ar port
+Specifies the port to connect to on the remote host.
+.It Fl p
+Preserves modification times, access times, and modes from the
+original files transferred.
+.It Fl q
+Quiet mode: disables the progress meter as well as warning and
+diagnostic messages from
+.Xr ssh 1 .
.It Fl R Ar num_requests
Specify how many requests may be outstanding at any one time.
Increasing this may slightly improve file transfer speed
but will increase memory usage.
-The default is 16 outstanding requests.
+The default is 64 outstanding requests.
+.It Fl r
+Recursively copy entire directories when uploading and downloading.
+Note that
+.Nm
+does not follow symbolic links encountered in the tree traversal.
.It Fl S Ar program
Name of the
.Ar program
.Nm
understands a set of commands similar to those of
.Xr ftp 1 .
-Commands are case insensitive and pathnames may be enclosed in quotes if they
-contain spaces.
-.Bl -tag -width "lmdir path"
+Commands are case insensitive.
+Pathnames that contain spaces must be enclosed in quotes.
+Any special characters contained within pathnames that are recognized by
+.Xr glob 3
+must be escaped with backslashes
+.Pq Sq \e .
+.Bl -tag -width Ds
.It Ic bye
Quit
.Nm sftp .
.Ar path
to
.Ar grp .
+.Ar path
+may contain
+.Xr glob 3
+characters and may match multiple files.
.Ar grp
must be a numeric GID.
.It Ic chmod Ar mode Ar path
.Ar path
to
.Ar mode .
+.Ar path
+may contain
+.Xr glob 3
+characters and may match multiple files.
.It Ic chown Ar own Ar path
Change owner of file
.Ar path
to
.Ar own .
+.Ar path
+may contain
+.Xr glob 3
+characters and may match multiple files.
.Ar own
must be a numeric UID.
+.It Xo Ic df
+.Op Fl hi
+.Op Ar path
+.Xc
+Display usage information for the filesystem holding the current directory
+(or
+.Ar path
+if specified).
+If the
+.Fl h
+flag is specified, the capacity information will be displayed using
+"human-readable" suffixes.
+The
+.Fl i
+flag requests display of inode information in addition to capacity information.
+This command is only supported on servers that implement the
+.Dq statvfs@openssh.com
+extension.
.It Ic exit
Quit
.Nm sftp .
.It Xo Ic get
-.Op Ar flags
+.Op Fl Ppr
.Ar remote-path
.Op Ar local-path
.Xc
If the local
path name is not specified, it is given the same name it has on the
remote machine.
-If the
+.Ar remote-path
+may contain
+.Xr glob 3
+characters and may match multiple files.
+If it does and
+.Ar local-path
+is specified, then
+.Ar local-path
+must specify a directory.
+.Pp
+If either the
.Fl P
-flag is specified, then the file's full permission and access time are
+or
+.Fl p
+flag is specified, then full file permissions and access times are
copied too.
+.Pp
+If the
+.Fl r
+flag is specified then directories will be copied recursively.
+Note that
+.Nm
+does not follow symbolic links when performing recursive transfers.
.It Ic help
Display help text.
.It Ic lcd Ar path
or current directory if
.Ar path
is not specified.
+.Ar ls-options
+may contain any flags supported by the local system's
+.Xr ls 1
+command.
+.Ar path
+may contain
+.Xr glob 3
+characters and may match multiple files.
.It Ic lmkdir Ar path
Create local directory specified by
.Ar path .
.It Ic lpwd
Print local working directory.
.It Xo Ic ls
-.Op Ar flags
+.Op Fl 1aflnrSt
.Op Ar path
.Xc
-Display remote directory listing of either
+Display a remote directory listing of either
.Ar path
-or current directory if
+or the current directory if
.Ar path
is not specified.
-If the
-.Fl l
-flag is specified, then display additional details including permissions
-and ownership information.
-The
-.Fl n
-flag will produce a long listing with user and group information presented
-numerically.
+.Ar path
+may contain
+.Xr glob 3
+characters and may match multiple files.
.Pp
-By default,
+The following flags are recognized and alter the behaviour of
.Ic ls
-listings are sorted in lexicographical order.
-This may be changed by specifying the
-.Fl S
-(sort by file size),
-.Fl t
-(sort by last modification time), or
-.Fl f
-(don't sort at all) flags.
-Additionally, the sort order may be reversed using the
-.Fl r
-flag.
+accordingly:
+.Bl -tag -width Ds
+.It Fl 1
+Produce single columnar output.
+.It Fl a
+List files beginning with a dot
+.Pq Sq \&. .
+.It Fl f
+Do not sort the listing.
+The default sort order is lexicographical.
+.It Fl l
+Display additional details including permissions
+and ownership information.
+.It Fl n
+Produce a long listing with user and group information presented
+numerically.
+.It Fl r
+Reverse the sort order of the listing.
+.It Fl S
+Sort the listing by file size.
+.It Fl t
+Sort the listing by last modification time.
+.El
.It Ic lumask Ar umask
Set local umask to
.Ar umask .
.It Ic progress
Toggle display of progress meter.
.It Xo Ic put
-.Op Ar flags
+.Op Fl Ppr
.Ar local-path
.Op Ar remote-path
.Xc
and store it on the remote machine.
If the remote path name is not specified, it is given the same name it has
on the local machine.
-If the
+.Ar local-path
+may contain
+.Xr glob 3
+characters and may match multiple files.
+If it does and
+.Ar remote-path
+is specified, then
+.Ar remote-path
+must specify a directory.
+.Pp
+If ether the
.Fl P
-flag is specified, then the file's full permission and access time are
+or
+.Fl p
+flag is specified, then full file permissions and access times are
copied too.
+.Pp
+If the
+.Fl r
+flag is specified then directories will be copied recursively.
+Note that
+.Nm
+does not follow symbolic links when performing recursive transfers.
.It Ic pwd
Display remote working directory.
.It Ic quit
Display the
.Nm
protocol version.
-.It Ic \&! Ar command
+.It Ic \&! Ns Ar command
Execute
.Ar command
in local shell.
.El
.Sh SEE ALSO
.Xr ftp 1 ,
+.Xr ls 1 ,
.Xr scp 1 ,
.Xr ssh 1 ,
.Xr ssh-add 1 ,
.Xr ssh-keygen 1 ,
+.Xr glob 3 ,
.Xr ssh_config 5 ,
.Xr sftp-server 8 ,
.Xr sshd 8