sftp Command Line Utility
The sftp command line utility is an interactive file transfer program, similar to ftp, which performs all operations over an encrypted Secure Shell transport. It can also use many features of ssh, such as public key authentication.
If you don't specify files on the command line, sftp enters an interactive command mode. You can use any of the interactive commands documented below. To script a series of commands you can use the batch file option (-B).
If you specify files on the command line, sftp transfers the files and then exits.
Note: You can reuse an existing Secure Shell connection. However, to do so you must explicitly enable this on each command line, or set the SSHConnectionReUse environment variable to Yes. For details, see Connection Reuse in Secure Shell Sessions.
Command Line Options
Transfer files in ASCII mode.
Sets the maximum buffer size for one request. Valid values are 1024 - 32768.
After a successful login, executes each command in the specified batch file and then terminates the connection. For example, the following command connects to myhost using myname and executes the commands in myfile. After all commands in the file are executed, the connection is terminated.
sftp -B c:\mypath\myfile myhost.com myname
The batch file can use any of the interactive commands documented below.
Note: Semicolons are not supported for comments in scripts supplied to the sftp command line using the -B option. Use the number sign (#) to mark comments in these batch files.
A comma-separated list of ciphers specified in order of preference. The default is "aes128-ctr,aes128-cbc,aes192-ctr,aes192-cbc,aes256-ctr,aes256-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour". If the connection is set to run in FIPS mode, the default is "aes128-ctr,aes128-cbc,aes192-ctr,aes192-cbc,aes256-ctr,aes256-cbc,3des-cbc".
Protocol version 1 (which is deprecated and not recommended) allows specification of a single cipher. The supported values are "3des", "blowfish", and "des".
Enables compression of all transmitted data. Compression is desirable on modem lines and other slow connections, but will only slow down response rate on fast networks.
Force target to be a directory.
Specifies an alternate configuration file to use for this connection. If a configuration file is given on the command line, other configuration files are ignored.
Specifies which SSH configuration scheme to use for this connection.
Specifies a private key to use for key authentication. Key files can also be specified on a per-host basis in the configuration file. It is possible to have multiple -i options (and multiple keys specified in a configuration file). Use quotation marks if the file or path includes spaces.
Sets any option that is supported in the configuration file. For example:
ssh "-o FIPSMode=yes" myuser@myhost
Preserve time stamps and file attributes.
Enables quiet mode, which causes all warning and diagnostic messages, including banners, to be suppressed.
Specifies the maximum number of concurrent requests. Increasing this may slightly improve file transfer speed but will increase memory usage. The default is 16 outstanding requests.
Specifies the ssh subsystem.
Program to use for encrypted connections.
Remove the source file after copying.
Sets the debug level to verbose mode, which is equivalent to setting the debug level to 2.
Displays product name and version information and exits. If other options are specified on the command line, they are ignored.
Once in interactive mode, sftp understands a set of commands similar, but not identical to standard ftp commands. Commands are case insensitive. Use quotation marks if you specify a file or path name that includes spaces.
Set transfer type to ASCII.
Set transfer type to binary.
Change remote directory to path.
Changes the permissions associated with path. Use mode to specify a three digit numeric permissions.
Change local directory to path.
get remote-path [local-path]
Retrieve the 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.
Displays the file extensions that will use ascii transfer. Use setext to modify this list.
Display help text.
lls [ls-options [path]]
Display local directory listing of either path or current directory if path is not specified.
Create local directory specified by path.
Print local working directory.
Display remote directory listing of either path or current directory if path is not specified.
Create remote directory specified by path.
put local-path [local-path]
Upload 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.
Display remote working directory.
reget remote-file [local-file]
Resume the specified transfer. This works like the get command, but checks for the presence of a partially written local file and, if it is found, starts the transfer where the last attempt left off.
rename oldpath newpath
Rename remote file from oldpath to newpath.
Remove remote directory specified by path.
Delete remote file specified by path.
Sets the file extensions that will use ascii transfer. Wildcard characters are supported. When no argument is given, no file extensions use ascii transfer.
Display sftp version.
Synonym for help.