1.5 SFTP
sftp – OpenSSH secure file transfer
1.5.1 Synopsis
sftp [-46AaCfNpqrv] [-B buffer_size] [-b batchfile] [-c cipher] |
[-D sftp_server_path] [-F ssh_config] [-i identity_file] |
[-J destination] [-l limit] [-o ssh_option] [-P port] |
[-R num_requests] [-S program] [-s subsystem | sftp_server] |
destination |
1.5.2 Description
sftp is a file transfer program, similar to ftp(1), which performs all operations over an encrypted ssh(1) transport. It may also use many features of ssh, such as public key authentication and compression.
[user @]host[:path]
sftp://[user @]host[:port][/path]
If no path is specified, or if the path is a directory, sftp will log in to the specified host and enter interactive command mode, changing to the remote directory if one was specified. An optional trailing slash can be used to force the path to be interpreted as a directory.
Since the destination formats use colon characters to delimit host names from path names or port numbers, IPv6 addresses must be enclosed in square brackets to avoid ambiguity.
1.5.3 Options
-B buffer_size
Specify the size of the buffer that sftp uses when transferring files. Larger buffers require fewer round trips at the cost of higher memory consumption. The default is 32768 bytes.
-C
Enables compression (via ssh’s -C flag).
-l limit
Limits the used bandwidth, specified in Kbit/s.
1.5.4 Interactive commands
Once in interactive mode, sftp understands a set of commands similar to those of ftp(1). Commands are case insensitive. Path names that contain spaces must be enclosed in quotes. Any special characters contained within pathnames that are recognized by glob(3) must be escaped with backslashes. Globs work.
help, ?
Display help text.
version
Display the sftp protocol version.
bye, quit
Quit sftp.
pwd
Display remote working directory.
lpwd
Print local working directory.
ls [-1afhlnrSt] [path]
Display a remote directory listing of either path or the current directory if path is not specified.
lls [ls-options [path]]
Display local directory listing of either path or current directory if path is not specified. ls-options may contain any flags supported by the local system’s ls(1) command.
cd [path]
Change remote directory to path. If path is not specified, then change directory to the one the session started in.
lcd [path]
Change local directory to path. If path is not specified, then change directory to the local user’s home directory.
mkdir path
Create remote directory specified by path.
lmkdir path
Create local directory specified by path.
get [-afpR] 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. Flags:-a
Attempt to resume partial transfers of existing files.
-f
fsync(2) will be called after the file transfer has completed to flush the file to disk.
-p
Full file permissions and access times are copied too.
-R
Directories will be copied recursively. Note that sftp does not follow symbolic links when performing recursive transfers.
put [-afpR] local-path [remote-path]
Upload local-path and store it on the remote machine. Same as above.
rename oldpath newpath
Rename remote file from oldpath to newpath.
rm path
Delete remote file specified by path.
rmdir path
Remove remote directory specified by path.
pwd
Display remote working directory.
progress
Toggle display of progress meter.
!command
Execute command in local shell.
!
Escape to local shell.
1.5.5 Example
$ sftp institute:public_html/manual/ |
Connected to institute. |
Changing to: /home/minuszero/public_html/manual/ |
sftp> put -fp *.html |
sftp> bye |
1.5.6 See also
ftp(1), ls(1), ssh(1), glob(7), sshd(8)