$FreeBSD: head/crypto/openssh/sftp.1 224638 2011-08-03 19:14:22Z brooks $
Copyright (c) 2001 Damien Miller. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(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 December 4, 2010 .Dt SFTP 1 .Os .Sh NAME .Nm sftp .Nd secure file transfer program .Sh SYNOPSIS .Nm sftp k -words .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 l Ar limit .Op Fl o Ar ssh_option .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 Ar user Ns @ Oc Ns .Ar host Ns Op : Ns Ar .Nm sftp .Oo .Ar user Ns @ Oc Ns .Ar host Ns Oo : Ns Ar dir Ns .Op Ar / .Oc .Nm sftp .Fl b Ar batchfile .Oo Ar user Ns @ Oc Ns Ar host .Sh DESCRIPTION .Nm is an interactive file transfer program, similar to .Xr ftp 1 , which performs all operations over an encrypted .Xr ssh 1 transport. It may also use many features of ssh, such as public key authentication and compression. .Nm connects and logs into the specified .Ar host , then enters an interactive command mode.
p The second usage format will retrieve files automatically if a non-interactive authentication method is used; otherwise it will do so after successful interactive authentication.
p The third usage format allows .Nm to start in a remote directory.
p The final usage format allows for automated sessions using the .Fl b option. 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 .Xr ssh-keygen 1 for details). The options are as follows: l -tag -width Ds t Fl 1 Specify the use of protocol version 1. t Fl 2 Specify the use of protocol version 2. t Fl 4 Forces .Nm to use IPv4 addresses only. t Fl 6 Forces .Nm to use IPv6 addresses only. t Fl B Ar buffer_size Specify the size of the buffer that .Nm uses when transferring files. Larger buffers require fewer round trips at the cost of higher memory consumption. The default is 32768 bytes. t Fl b Ar batchfile Batch mode reads a series of commands from an input .Ar batchfile instead of .Em stdin . Since it lacks user interaction it should be used in conjunction with non-interactive authentication. A .Ar batchfile of .Sq - may be used to indicate standard input. .Nm will abort if any of the following commands fail: c get , put , rename , ln , c rm , mkdir , chdir , ls , c lchdir , chmod , chown , c chgrp , lpwd , df , symlink , and c lmkdir . Termination on error can be suppressed on a command by command basis by prefixing the command with a .Sq - character (for example, c -rm /tmp/blah* ) . t Fl C Enables compression (via ssh's .Fl C flag). t Fl c Ar cipher Selects the cipher to use for encrypting the data transfers. This option is directly passed to .Xr ssh 1 . t 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. t 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 . t 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 . t Fl l Ar limit Limits the used bandwidth, specified in Kbit/s. t Fl o Ar ssh_option Can be used to pass options to .Nm ssh in the format used in .Xr ssh_config 5 . This is useful for specifying options for which there is no separate .Nm sftp command-line flag. For example, to specify an alternate port use: c sftp -oPort=24 . For full details of the options listed below, and their possible values, see .Xr ssh_config 5 .
p l -tag -width Ds -offset indent -compact t AddressFamily t BatchMode t BindAddress t ChallengeResponseAuthentication t CheckHostIP t Cipher t Ciphers t Compression t CompressionLevel t ConnectionAttempts t ConnectTimeout t ControlMaster t ControlPath t GlobalKnownHostsFile t GSSAPIAuthentication t GSSAPIDelegateCredentials t HashKnownHosts t Host t HostbasedAuthentication t HostKeyAlgorithms t HostKeyAlias t HostName t IdentityFile t IdentitiesOnly t IPQoS t KbdInteractiveDevices t KexAlgorithms t LogLevel t MACs t NoHostAuthenticationForLocalhost t NumberOfPasswordPrompts t PasswordAuthentication t PKCS11Provider t Port t PreferredAuthentications t Protocol t ProxyCommand t PubkeyAuthentication t RekeyLimit t RhostsRSAAuthentication t RSAAuthentication t SendEnv t ServerAliveInterval t ServerAliveCountMax t StrictHostKeyChecking t TCPKeepAlive t UsePrivilegedPort t User t UserKnownHostsFile t VerifyHostKeyDNS .El t Fl P Ar port Specifies the port to connect to on the remote host. t Fl p Preserves modification times, access times, and modes from the original files transferred. t Fl q Quiet mode: disables the progress meter as well as warning and diagnostic messages from .Xr ssh 1 . t 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 256 outstanding requests providing for 8MB of outstanding data with a 32KB buffer. t Fl r Recursively copy entire directories when uploading and downloading. Note that .Nm does not follow symbolic links encountered in the tree traversal. t Fl S Ar program Name of the .Ar program to use for the encrypted connection. The program must understand .Xr ssh 1 options. t Fl s Ar subsystem | sftp_server Specifies the SSH2 subsystem or the path for an sftp server on the remote host. A path is useful for using .Nm over protocol version 1, or when the remote .Xr sshd 8 does not have an sftp subsystem configured. t Fl v Raise logging level. This option is also passed to ssh. .El .Sh INTERACTIVE COMMANDS Once in interactive mode, .Nm understands a set of commands similar to those of .Xr ftp 1 . 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
q Sq \e . l -tag -width Ds t Ic bye Quit .Nm sftp . t Ic cd Ar path Change remote directory to .Ar path . t Ic chgrp Ar grp Ar path Change group of file .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. t Ic chmod Ar mode Ar path Change permissions of file .Ar path to .Ar mode . .Ar path may contain .Xr glob 3 characters and may match multiple files. t 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. t 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. t Ic exit Quit .Nm sftp . t Xo Ic get .Op Fl Ppr .Ar remote-path .Op Ar local-path .Xc Retrieve the .Ar remote-path and store it on the local machine. If the local path name is not specified, it is given the same name it has on the remote machine. .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.
p If either the .Fl P or .Fl p flag is specified, then full file permissions and access times are copied too.
p 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. t Ic help Display help text. t Ic lcd Ar path Change local directory to .Ar path . t Ic lls Op Ar ls-options Op Ar path Display local directory listing of either .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. t Ic lmkdir Ar path Create local directory specified by .Ar path . t Xo Ic ln .Op Fl s .Ar oldpath .Ar newpath .Xc Create a link from .Ar oldpath to .Ar newpath . If the .Fl s flag is specified the created link is a symbolic link, otherwise it is a hard link. t Ic lpwd Print local working directory. t Xo Ic ls .Op Fl 1afhlnrSt .Op Ar path .Xc Display a remote directory listing of either .Ar path or the current directory if .Ar path is not specified. .Ar path may contain .Xr glob 3 characters and may match multiple files.
p The following flags are recognized and alter the behaviour of c ls accordingly: l -tag -width Ds t Fl 1 Produce single columnar output. t Fl a List files beginning with a dot
q Sq . . t Fl f Do not sort the listing. The default sort order is lexicographical. t Fl h When used with a long format option, use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte, Petabyte, and Exabyte in order to reduce the number of digits to four or fewer using powers of 2 for sizes (K=1024, M=1048576, etc.). t Fl l Display additional details including permissions and ownership information. t Fl n Produce a long listing with user and group information presented numerically. t Fl r Reverse the sort order of the listing. t Fl S Sort the listing by file size. t Fl t Sort the listing by last modification time. .El t Ic lumask Ar umask Set local umask to .Ar umask . t Ic mkdir Ar path Create remote directory specified by .Ar path . t Ic progress Toggle display of progress meter. t Xo Ic put .Op Fl Ppr .Ar local-path .Op Ar remote-path .Xc Upload .Ar local-path 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. .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.
p If ether the .Fl P or .Fl p flag is specified, then full file permissions and access times are copied too.
p 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. t Ic pwd Display remote working directory. t Ic quit Quit .Nm sftp . t Ic rename Ar oldpath Ar newpath Rename remote file from .Ar oldpath to .Ar newpath . t Ic rm Ar path Delete remote file specified by .Ar path . t Ic rmdir Ar path Remove remote directory specified by .Ar path . t Ic symlink Ar oldpath Ar newpath Create a symbolic link from .Ar oldpath to .Ar newpath . t Ic version Display the .Nm protocol version. t Ic ! Ns Ar command Execute .Ar command in local shell. t Ic ! Escape to local shell. t Ic ? Synonym for help. .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 .Rs .%A T. Ylonen .%A S. Lehtinen .%T "SSH File Transfer Protocol" .%N draft-ietf-secsh-filexfer-00.txt .%D January 2001 .%O work in progress material .Re