1 SFTP(1) General Commands Manual SFTP(1)
4 sftp M-bM-^@M-^S secure file transfer program
7 sftp [-46aCfpqrv] [-B buffer_size] [-b batchfile] [-c cipher]
8 [-D sftp_server_path] [-F ssh_config] [-i identity_file] [-l limit]
9 [-o ssh_option] [-P port] [-R num_requests] [-S program]
10 [-s subsystem | sftp_server] destination
13 sftp is a file transfer program, similar to ftp(1), which performs all
14 operations over an encrypted ssh(1) transport. It may also use many
15 features of ssh, such as public key authentication and compression.
17 The destination may be specified either as [user@]host[:path] or as a URI
18 in the form sftp://[user@]host[:port][/path].
20 If the destination includes a path and it is not a directory, sftp will
21 retrieve files automatically if a non-interactive authentication method
22 is used; otherwise it will do so after successful interactive
25 If no path is specified, or if the path is a directory, sftp will log in
26 to the specified host and enter interactive command mode, changing to the
27 remote directory if one was specified. An optional trailing slash can be
28 used to force the path to be interpreted as a directory.
30 Since the destination formats use colon characters to delimit host names
31 from path names or port numbers, IPv6 addresses must be enclosed in
32 square brackets to avoid ambiguity.
34 The options are as follows:
36 -4 Forces sftp to use IPv4 addresses only.
38 -6 Forces sftp to use IPv6 addresses only.
40 -a Attempt to continue interrupted transfers rather than overwriting
41 existing partial or complete copies of files. If the partial
42 contents differ from those being transferred, then the resultant
43 file is likely to be corrupt.
46 Specify the size of the buffer that sftp uses when transferring
47 files. Larger buffers require fewer round trips at the cost of
48 higher memory consumption. The default is 32768 bytes.
51 Batch mode reads a series of commands from an input batchfile
52 instead of stdin. Since it lacks user interaction it should be
53 used in conjunction with non-interactive authentication to
54 obviate the need to enter a password at connection time (see
55 sshd(8) and ssh-keygen(1) for details). A batchfile of M-bM-^@M-^X-M-bM-^@M-^Y may
56 be used to indicate standard input. sftp will abort if any of
57 the following commands fail: get, put, reget, reput, rename, ln,
58 rm, mkdir, chdir, ls, lchdir, chmod, chown, chgrp, lpwd, df,
59 symlink, and lmkdir. Termination on error can be suppressed on a
60 command by command basis by prefixing the command with a M-bM-^@M-^X-M-bM-^@M-^Y
61 character (for example, -rm /tmp/blah*).
63 -C Enables compression (via ssh's -C flag).
66 Selects the cipher to use for encrypting the data transfers.
67 This option is directly passed to ssh(1).
70 Connect directly to a local sftp server (rather than via ssh(1)).
71 This option may be useful in debugging the client and server.
74 Specifies an alternative per-user configuration file for ssh(1).
75 This option is directly passed to ssh(1).
77 -f Requests that files be flushed to disk immediately after
78 transfer. When uploading files, this feature is only enabled if
79 the server implements the "fsync@openssh.com" extension.
82 Selects the file from which the identity (private key) for public
83 key authentication is read. This option is directly passed to
87 Limits the used bandwidth, specified in Kbit/s.
90 Can be used to pass options to ssh in the format used in
91 ssh_config(5). This is useful for specifying options for which
92 there is no separate sftp command-line flag. For example, to
93 specify an alternate port use: sftp -oPort=24. For full details
94 of the options listed below, and their possible values, see
102 CanonicalizeFallbackLocal
105 CanonicalizePermittedCNAMEs
107 ChallengeResponseAuthentication
118 GSSAPIDelegateCredentials
121 HostbasedAuthentication
130 KbdInteractiveAuthentication
131 KbdInteractiveDevices
135 NoHostAuthenticationForLocalhost
136 NumberOfPasswordPrompts
137 PasswordAuthentication
140 PreferredAuthentications
143 PubkeyAcceptedKeyTypes
149 StrictHostKeyChecking
158 Specifies the port to connect to on the remote host.
160 -p Preserves modification times, access times, and modes from the
161 original files transferred.
163 -q Quiet mode: disables the progress meter as well as warning and
164 diagnostic messages from ssh(1).
167 Specify how many requests may be outstanding at any one time.
168 Increasing this may slightly improve file transfer speed but will
169 increase memory usage. The default is 64 outstanding requests.
171 -r Recursively copy entire directories when uploading and
172 downloading. Note that sftp does not follow symbolic links
173 encountered in the tree traversal.
176 Name of the program to use for the encrypted connection. The
177 program must understand ssh(1) options.
179 -s subsystem | sftp_server
180 Specifies the SSH2 subsystem or the path for an sftp server on
181 the remote host. A path is useful when the remote sshd(8) does
182 not have an sftp subsystem configured.
184 -v Raise logging level. This option is also passed to ssh.
187 Once in interactive mode, sftp understands a set of commands similar to
188 those of ftp(1). Commands are case insensitive. Pathnames that contain
189 spaces must be enclosed in quotes. Any special characters contained
190 within pathnames that are recognized by glob(3) must be escaped with
191 backslashes (M-bM-^@M-^X\M-bM-^@M-^Y).
196 Change remote directory to path. If path is not specified, then
197 change directory to the one the session started in.
200 Change group of file path to grp. path may contain glob(3)
201 characters and may match multiple files. grp must be a numeric
205 Change permissions of file path to mode. path may contain
206 glob(3) characters and may match multiple files.
209 Change owner of file path to own. path may contain glob(3)
210 characters and may match multiple files. own must be a numeric
214 Display usage information for the filesystem holding the current
215 directory (or path if specified). If the -h flag is specified,
216 the capacity information will be displayed using "human-readable"
217 suffixes. The -i flag requests display of inode information in
218 addition to capacity information. This command is only supported
219 on servers that implement the M-bM-^@M-^\statvfs@openssh.comM-bM-^@M-^] extension.
223 get [-afPpr] remote-path [local-path]
224 Retrieve the remote-path and store it on the local machine. If
225 the local path name is not specified, it is given the same name
226 it has on the remote machine. remote-path may contain glob(3)
227 characters and may match multiple files. If it does and
228 local-path is specified, then local-path must specify a
231 If the -a flag is specified, then attempt to resume partial
232 transfers of existing files. Note that resumption assumes that
233 any partial copy of the local file matches the remote copy. If
234 the remote file contents differ from the partial local copy then
235 the resultant file is likely to be corrupt.
237 If the -f flag is specified, then fsync(2) will be called after
238 the file transfer has completed to flush the file to disk.
240 If either the -P or -p flag is specified, then full file
241 permissions and access times are copied too.
243 If the -r flag is specified then directories will be copied
244 recursively. Note that sftp does not follow symbolic links when
245 performing recursive transfers.
247 help Display help text.
250 Change local directory to path. If path is not specified, then
251 change directory to the local user's home directory.
253 lls [ls-options [path]]
254 Display local directory listing of either path or current
255 directory if path is not specified. ls-options may contain any
256 flags supported by the local system's ls(1) command. path may
257 contain glob(3) characters and may match multiple files.
260 Create local directory specified by path.
262 ln [-s] oldpath newpath
263 Create a link from oldpath to newpath. If the -s flag is
264 specified the created link is a symbolic link, otherwise it is a
267 lpwd Print local working directory.
269 ls [-1afhlnrSt] [path]
270 Display a remote directory listing of either path or the current
271 directory if path is not specified. path may contain glob(3)
272 characters and may match multiple files.
274 The following flags are recognized and alter the behaviour of ls
277 -1 Produce single columnar output.
279 -a List files beginning with a dot (M-bM-^@M-^X.M-bM-^@M-^Y).
281 -f Do not sort the listing. The default sort order is
284 -h When used with a long format option, use unit suffixes:
285 Byte, Kilobyte, Megabyte, Gigabyte, Terabyte, Petabyte,
286 and Exabyte in order to reduce the number of digits to
287 four or fewer using powers of 2 for sizes (K=1024,
290 -l Display additional details including permissions and
291 ownership information.
293 -n Produce a long listing with user and group information
294 presented numerically.
296 -r Reverse the sort order of the listing.
298 -S Sort the listing by file size.
300 -t Sort the listing by last modification time.
303 Set local umask to umask.
306 Create remote directory specified by path.
309 Toggle display of progress meter.
311 put [-afPpr] local-path [remote-path]
312 Upload local-path and store it on the remote machine. If the
313 remote path name is not specified, it is given the same name it
314 has on the local machine. local-path may contain glob(3)
315 characters and may match multiple files. If it does and
316 remote-path is specified, then remote-path must specify a
319 If the -a flag is specified, then attempt to resume partial
320 transfers of existing files. Note that resumption assumes that
321 any partial copy of the remote file matches the local copy. If
322 the local file contents differ from the remote local copy then
323 the resultant file is likely to be corrupt.
325 If the -f flag is specified, then a request will be sent to the
326 server to call fsync(2) after the file has been transferred.
327 Note that this is only supported by servers that implement the
328 "fsync@openssh.com" extension.
330 If either the -P or -p flag is specified, then full file
331 permissions and access times are copied too.
333 If the -r flag is specified then directories will be copied
334 recursively. Note that sftp does not follow symbolic links when
335 performing recursive transfers.
337 pwd Display remote working directory.
341 reget [-Ppr] remote-path [local-path]
342 Resume download of remote-path. Equivalent to get with the -a
345 reput [-Ppr] [local-path] remote-path
346 Resume upload of [local-path]. Equivalent to put with the -a
349 rename oldpath newpath
350 Rename remote file from oldpath to newpath.
353 Delete remote file specified by path.
356 Remove remote directory specified by path.
358 symlink oldpath newpath
359 Create a symbolic link from oldpath to newpath.
362 Display the sftp protocol version.
365 Execute command in local shell.
367 ! Escape to local shell.
372 ftp(1), ls(1), scp(1), ssh(1), ssh-add(1), ssh-keygen(1), glob(3),
373 ssh_config(5), sftp-server(8), sshd(8)
375 T. Ylonen and S. Lehtinen, SSH File Transfer Protocol, draft-ietf-secsh-
376 filexfer-00.txt, January 2001, work in progress material.
378 OpenBSD 6.2 February 23, 2018 OpenBSD 6.2