1 SFTP(1) General Commands Manual SFTP(1)
4 sftp M-bM-^@M-^S secure file transfer program
7 sftp [-1246aCfpqrv] [-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] host
11 sftp [user@]host[:file ...]
12 sftp [user@]host[:dir[/]]
13 sftp -b batchfile [user@]host
16 sftp is an interactive file transfer program, similar to ftp(1), which
17 performs all operations over an encrypted ssh(1) transport. It may also
18 use many features of ssh, such as public key authentication and
19 compression. sftp connects and logs into the specified host, then enters
20 an interactive command mode.
22 The second usage format will retrieve files automatically if a non-
23 interactive authentication method is used; otherwise it will do so after
24 successful interactive authentication.
26 The third usage format allows sftp to start in a remote directory.
28 The final usage format allows for automated sessions using the -b option.
29 In such cases, it is necessary to configure non-interactive
30 authentication to obviate the need to enter a password at connection time
31 (see sshd(8) and ssh-keygen(1) for details).
33 Since some usage formats use colon characters to delimit host names from
34 path names, IPv6 addresses must be enclosed in square brackets to avoid
37 The options are as follows:
39 -1 Specify the use of protocol version 1.
41 -2 Specify the use of protocol version 2.
43 -4 Forces sftp to use IPv4 addresses only.
45 -6 Forces sftp to use IPv6 addresses only.
47 -a Attempt to continue interrupted transfers rather than overwriting
48 existing partial or complete copies of files. If the partial
49 contents differ from those being transferred, then the resultant
50 file is likely to be corrupt.
53 Specify the size of the buffer that sftp uses when transferring
54 files. Larger buffers require fewer round trips at the cost of
55 higher memory consumption. The default is 32768 bytes.
58 Batch mode reads a series of commands from an input batchfile
59 instead of stdin. Since it lacks user interaction it should be
60 used in conjunction with non-interactive authentication. A
61 batchfile of M-bM-^@M-^X-M-bM-^@M-^Y may be used to indicate standard input. sftp
62 will abort if any of the following commands fail: get, put,
63 reget, reput, rename, ln, rm, mkdir, chdir, ls, lchdir, chmod,
64 chown, chgrp, lpwd, df, symlink, and lmkdir. Termination on
65 error can be suppressed on a command by command basis by
66 prefixing the command with a M-bM-^@M-^X-M-bM-^@M-^Y character (for example, -rm
69 -C Enables compression (via ssh's -C flag).
72 Selects the cipher to use for encrypting the data transfers.
73 This option is directly passed to ssh(1).
76 Connect directly to a local sftp server (rather than via ssh(1)).
77 This option may be useful in debugging the client and server.
80 Specifies an alternative per-user configuration file for ssh(1).
81 This option is directly passed to ssh(1).
83 -f Requests that files be flushed to disk immediately after
84 transfer. When uploading files, this feature is only enabled if
85 the server implements the "fsync@openssh.com" extension.
88 Selects the file from which the identity (private key) for public
89 key authentication is read. This option is directly passed to
93 Limits the used bandwidth, specified in Kbit/s.
96 Can be used to pass options to ssh in the format used in
97 ssh_config(5). This is useful for specifying options for which
98 there is no separate sftp command-line flag. For example, to
99 specify an alternate port use: sftp -oPort=24. For full details
100 of the options listed below, and their possible values, see
107 CanonicalizeFallbackLocal
110 CanonicalizePermittedCNAMEs
112 ChallengeResponseAuthentication
125 GSSAPIDelegateCredentials
128 HostbasedAuthentication
137 KbdInteractiveAuthentication
138 KbdInteractiveDevices
142 NoHostAuthenticationForLocalhost
143 NumberOfPasswordPrompts
144 PasswordAuthentication
147 PreferredAuthentications
153 RhostsRSAAuthentication
158 StrictHostKeyChecking
167 Specifies the port to connect to on the remote host.
169 -p Preserves modification times, access times, and modes from the
170 original files transferred.
172 -q Quiet mode: disables the progress meter as well as warning and
173 diagnostic messages from ssh(1).
176 Specify how many requests may be outstanding at any one time.
177 Increasing this may slightly improve file transfer speed but will
178 increase memory usage. The default is 64 outstanding requests.
180 -r Recursively copy entire directories when uploading and
181 downloading. Note that sftp does not follow symbolic links
182 encountered in the tree traversal.
185 Name of the program to use for the encrypted connection. The
186 program must understand ssh(1) options.
188 -s subsystem | sftp_server
189 Specifies the SSH2 subsystem or the path for an sftp server on
190 the remote host. A path is useful for using sftp over protocol
191 version 1, or when the remote sshd(8) does not have an sftp
192 subsystem configured.
194 -v Raise logging level. This option is also passed to ssh.
197 Once in interactive mode, sftp understands a set of commands similar to
198 those of ftp(1). Commands are case insensitive. Pathnames that contain
199 spaces must be enclosed in quotes. Any special characters contained
200 within pathnames that are recognized by glob(3) must be escaped with
201 backslashes (M-bM-^@M-^X\M-bM-^@M-^Y).
206 Change remote directory to path.
209 Change group of file path to grp. path may contain glob(3)
210 characters and may match multiple files. grp must be a numeric
214 Change permissions of file path to mode. path may contain
215 glob(3) characters and may match multiple files.
218 Change owner of file path to own. path may contain glob(3)
219 characters and may match multiple files. own must be a numeric
223 Display usage information for the filesystem holding the current
224 directory (or path if specified). If the -h flag is specified,
225 the capacity information will be displayed using "human-readable"
226 suffixes. The -i flag requests display of inode information in
227 addition to capacity information. This command is only supported
228 on servers that implement the M-bM-^@M-^\statvfs@openssh.comM-bM-^@M-^] extension.
232 get [-afPpr] remote-path [local-path]
233 Retrieve the remote-path and store it on the local machine. If
234 the local path name is not specified, it is given the same name
235 it has on the remote machine. remote-path may contain glob(3)
236 characters and may match multiple files. If it does and
237 local-path is specified, then local-path must specify a
240 If the -a flag is specified, then attempt to resume partial
241 transfers of existing files. Note that resumption assumes that
242 any partial copy of the local file matches the remote copy. If
243 the remote file contents differ from the partial local copy then
244 the resultant file is likely to be corrupt.
246 If the -f flag is specified, then fsync(2) will be called after
247 the file transfer has completed to flush the file to disk.
249 If either the -P or -p flag is specified, then full file
250 permissions and access times are copied too.
252 If the -r flag is specified then directories will be copied
253 recursively. Note that sftp does not follow symbolic links when
254 performing recursive transfers.
256 help Display help text.
259 Change local directory to path.
261 lls [ls-options [path]]
262 Display local directory listing of either path or current
263 directory if path is not specified. ls-options may contain any
264 flags supported by the local system's ls(1) command. path may
265 contain glob(3) characters and may match multiple files.
268 Create local directory specified by path.
270 ln [-s] oldpath newpath
271 Create a link from oldpath to newpath. If the -s flag is
272 specified the created link is a symbolic link, otherwise it is a
275 lpwd Print local working directory.
277 ls [-1afhlnrSt] [path]
278 Display a remote directory listing of either path or the current
279 directory if path is not specified. path may contain glob(3)
280 characters and may match multiple files.
282 The following flags are recognized and alter the behaviour of ls
285 -1 Produce single columnar output.
287 -a List files beginning with a dot (M-bM-^@M-^X.M-bM-^@M-^Y).
289 -f Do not sort the listing. The default sort order is
292 -h When used with a long format option, use unit suffixes:
293 Byte, Kilobyte, Megabyte, Gigabyte, Terabyte, Petabyte,
294 and Exabyte in order to reduce the number of digits to
295 four or fewer using powers of 2 for sizes (K=1024,
298 -l Display additional details including permissions and
299 ownership information.
301 -n Produce a long listing with user and group information
302 presented numerically.
304 -r Reverse the sort order of the listing.
306 -S Sort the listing by file size.
308 -t Sort the listing by last modification time.
311 Set local umask to umask.
314 Create remote directory specified by path.
317 Toggle display of progress meter.
319 put [-afPpr] local-path [remote-path]
320 Upload local-path and store it on the remote machine. If the
321 remote path name is not specified, it is given the same name it
322 has on the local machine. local-path may contain glob(3)
323 characters and may match multiple files. If it does and
324 remote-path is specified, then remote-path must specify a
327 If the -a flag is specified, then attempt to resume partial
328 transfers of existing files. Note that resumption assumes that
329 any partial copy of the remote file matches the local copy. If
330 the local file contents differ from the remote local copy then
331 the resultant file is likely to be corrupt.
333 If the -f flag is specified, then a request will be sent to the
334 server to call fsync(2) after the file has been transferred.
335 Note that this is only supported by servers that implement the
336 "fsync@openssh.com" extension.
338 If either the -P or -p flag is specified, then full file
339 permissions and access times are copied too.
341 If the -r flag is specified then directories will be copied
342 recursively. Note that sftp does not follow symbolic links when
343 performing recursive transfers.
345 pwd Display remote working directory.
349 reget [-Ppr] remote-path [local-path]
350 Resume download of remote-path. Equivalent to get with the -a
353 reput [-Ppr] [local-path] remote-path
354 Resume upload of [local-path]. Equivalent to put with the -a
357 rename oldpath newpath
358 Rename remote file from oldpath to newpath.
361 Delete remote file specified by path.
364 Remove remote directory specified by path.
366 symlink oldpath newpath
367 Create a symbolic link from oldpath to newpath.
370 Display the sftp protocol version.
373 Execute command in local shell.
375 ! Escape to local shell.
380 ftp(1), ls(1), scp(1), ssh(1), ssh-add(1), ssh-keygen(1), glob(3),
381 ssh_config(5), sftp-server(8), sshd(8)
383 T. Ylonen and S. Lehtinen, SSH File Transfer Protocol, draft-ietf-secsh-
384 filexfer-00.txt, January 2001, work in progress material.
386 OpenBSD 6.0 July 16, 2016 OpenBSD 6.0