1SFTP(1)                   BSD General Commands Manual                  SFTP(1)
2

NAME

4     sftp — secure file transfer program
5

SYNOPSIS

7     sftp [-46aCfpqrv] [-B buffer_size] [-b batchfile] [-c cipher]
8          [-D sftp_server_path] [-F ssh_config] [-i identity_file]
9          [-J destination] [-l limit] [-o ssh_option] [-P port]
10          [-R num_requests] [-S program] [-s subsystem | sftp_server]
11          destination
12

DESCRIPTION

14     sftp is a file transfer program, similar to ftp(1), which performs all
15     operations over an encrypted ssh(1) transport.  It may also use many fea‐
16     tures of ssh, such as public key authentication and compression.
17
18     The destination may be specified either as [user@]host[:path] or as a URI
19     in the form sftp://[user@]host[:port][/path].
20
21     If the destination includes a path and it is not a directory, sftp will
22     retrieve files automatically if a non-interactive authentication method
23     is used; otherwise it will do so after successful interactive authentica‐
24     tion.
25
26     If no path is specified, or if the path is a directory, sftp will log in
27     to the specified host and enter interactive command mode, changing to the
28     remote directory if one was specified.  An optional trailing slash can be
29     used to force the path to be interpreted as a directory.
30
31     Since the destination formats use colon characters to delimit host names
32     from path names or port numbers, IPv6 addresses must be enclosed in
33     square brackets to avoid ambiguity.
34
35     The options are as follows:
36
37     -4      Forces sftp to use IPv4 addresses only.
38
39     -6      Forces sftp to use IPv6 addresses only.
40
41     -a      Attempt to continue interrupted transfers rather than overwriting
42             existing partial or complete copies of files.  If the partial
43             contents differ from those being transferred, then the resultant
44             file is likely to be corrupt.
45
46     -B buffer_size
47             Specify the size of the buffer that sftp uses when transferring
48             files.  Larger buffers require fewer round trips at the cost of
49             higher memory consumption.  The default is 32768 bytes.
50
51     -b batchfile
52             Batch mode reads a series of commands from an input batchfile
53             instead of stdin.  Since it lacks user interaction it should be
54             used in conjunction with non-interactive authentication to obvi‐
55             ate the need to enter a password at connection time (see sshd(8)
56             and ssh-keygen(1) for details).
57
58             A batchfile of ‘-’ may be used to indicate standard input.  sftp
59             will abort if any of the following commands fail: get, put,
60             reget, reput, rename, ln, rm, mkdir, chdir, ls, lchdir, chmod,
61             chown, chgrp, lpwd, df, symlink, and lmkdir.
62
63             Termination on error can be suppressed on a command by command
64             basis by prefixing the command with a ‘-’ character (for example,
65             -rm /tmp/blah*).  Echo of the command may be suppressed by pre‐
66             fixing the command with a ‘@’ character.  These two prefixes may
67             be combined in any order, for example -@ls /bsd.
68
69     -C      Enables compression (via ssh's -C flag).
70
71     -c cipher
72             Selects the cipher to use for encrypting the data transfers.
73             This option is directly passed to ssh(1).
74
75     -D sftp_server_path
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.
78
79     -F ssh_config
80             Specifies an alternative per-user configuration file for ssh(1).
81             This option is directly passed to ssh(1).
82
83     -f      Requests that files be flushed to disk immediately after trans‐
84             fer.  When uploading files, this feature is only enabled if the
85             server implements the "fsync@openssh.com" extension.
86
87     -i identity_file
88             Selects the file from which the identity (private key) for public
89             key authentication is read.  This option is directly passed to
90             ssh(1).
91
92     -J destination
93             Connect to the target host by first making an sftp connection to
94             the jump host described by destination and then establishing a
95             TCP forwarding to the ultimate destination from there.  Multiple
96             jump hops may be specified separated by comma characters.  This
97             is a shortcut to specify a ProxyJump configuration directive.
98             This option is directly passed to ssh(1).
99
100     -l limit
101             Limits the used bandwidth, specified in Kbit/s.
102
103     -o ssh_option
104             Can be used to pass options to ssh in the format used in
105             ssh_config(5).  This is useful for specifying options for which
106             there is no separate sftp command-line flag.  For example, to
107             specify an alternate port use: sftp -oPort=24.  For full details
108             of the options listed below, and their possible values, see
109             ssh_config(5).
110
111                   AddressFamily
112                   BatchMode
113                   BindAddress
114                   BindInterface
115                   CanonicalDomains
116                   CanonicalizeFallbackLocal
117                   CanonicalizeHostname
118                   CanonicalizeMaxDots
119                   CanonicalizePermittedCNAMEs
120                   CASignatureAlgorithms
121                   CertificateFile
122                   ChallengeResponseAuthentication
123                   CheckHostIP
124                   Ciphers
125                   Compression
126                   ConnectionAttempts
127                   ConnectTimeout
128                   ControlMaster
129                   ControlPath
130                   ControlPersist
131                   GlobalKnownHostsFile
132                   GSSAPIAuthentication
133                   GSSAPIDelegateCredentials
134                   HashKnownHosts
135                   Host
136                   HostbasedAuthentication
137                   HostbasedKeyTypes
138                   HostKeyAlgorithms
139                   HostKeyAlias
140                   Hostname
141                   IdentitiesOnly
142                   IdentityAgent
143                   IdentityFile
144                   IPQoS
145                   KbdInteractiveAuthentication
146                   KbdInteractiveDevices
147                   KexAlgorithms
148                   LogLevel
149                   MACs
150                   NoHostAuthenticationForLocalhost
151                   NumberOfPasswordPrompts
152                   PasswordAuthentication
153                   PKCS11Provider
154                   Port
155                   PreferredAuthentications
156                   ProxyCommand
157                   ProxyJump
158                   PubkeyAcceptedKeyTypes
159                   PubkeyAuthentication
160                   RekeyLimit
161                   SendEnv
162                   ServerAliveInterval
163                   ServerAliveCountMax
164                   SetEnv
165                   StrictHostKeyChecking
166                   TCPKeepAlive
167                   UpdateHostKeys
168                   User
169                   UserKnownHostsFile
170                   VerifyHostKeyDNS
171
172     -P port
173             Specifies the port to connect to on the remote host.
174
175     -p      Preserves modification times, access times, and modes from the
176             original files transferred.
177
178     -q      Quiet mode: disables the progress meter as well as warning and
179             diagnostic messages from ssh(1).
180
181     -R num_requests
182             Specify how many requests may be outstanding at any one time.
183             Increasing this may slightly improve file transfer speed but will
184             increase memory usage.  The default is 64 outstanding requests.
185
186     -r      Recursively copy entire directories when uploading and download‐
187             ing.  Note that sftp does not follow symbolic links encountered
188             in the tree traversal.
189
190     -S program
191             Name of the program to use for the encrypted connection.  The
192             program must understand ssh(1) options.
193
194     -s subsystem | sftp_server
195             Specifies the SSH2 subsystem or the path for an sftp server on
196             the remote host.  A path is useful when the remote sshd(8) does
197             not have an sftp subsystem configured.
198
199     -v      Raise logging level.  This option is also passed to ssh.
200

INTERACTIVE COMMANDS

202     Once in interactive mode, sftp understands a set of commands similar to
203     those of ftp(1).  Commands are case insensitive.  Pathnames that contain
204     spaces must be enclosed in quotes.  Any special characters contained
205     within pathnames that are recognized by glob(3) must be escaped with
206     backslashes (‘\’).
207
208     bye     Quit sftp.
209
210     cd [path]
211             Change remote directory to path.  If path is not specified, then
212             change directory to the one the session started in.
213
214     chgrp [-h] grp path
215             Change group of file path to grp.  If the -h flag is specified,
216             then symlinks will not be followed.  path may contain glob(7)
217             characters and may match multiple files.  grp must be a numeric
218             GID.
219
220     chmod [-h] mode path
221             Change permissions of file path to mode.  If the -h flag is spec‐
222             ified, then symlinks will not be followed.  path may contain
223             glob(7) characters and may match multiple files.
224
225     chown [-h] own path
226             Change owner of file path to own.  If the -h flag is specified,
227             then symlinks will not be followed.  path may contain glob(7)
228             characters and may match multiple files.  own must be a numeric
229             UID.
230
231     df [-hi] [path]
232             Display usage information for the filesystem holding the current
233             directory (or path if specified).  If the -h flag is specified,
234             the capacity information will be displayed using "human-readable"
235             suffixes.  The -i flag requests display of inode information in
236             addition to capacity information.  This command is only supported
237             on servers that implement the “statvfs@openssh.com” extension.
238
239     exit    Quit sftp.
240
241     get [-afpR] remote-path [local-path]
242             Retrieve the remote-path and store it on the local machine.  If
243             the local path name is not specified, it is given the same name
244             it has on the remote machine.  remote-path may contain glob(7)
245             characters and may match multiple files.  If it does and
246             local-path is specified, then local-path must specify a direc‐
247             tory.
248
249             If the -a flag is specified, then attempt to resume partial
250             transfers of existing files.  Note that resumption assumes that
251             any partial copy of the local file matches the remote copy.  If
252             the remote file contents differ from the partial local copy then
253             the resultant file is likely to be corrupt.
254
255             If the -f flag is specified, then fsync(2) will be called after
256             the file transfer has completed to flush the file to disk.
257
258             If the -p flag is specified, then full file permissions and
259             access times are copied too.
260
261             If the -R flag is specified then directories will be copied
262             recursively.  Note that sftp does not follow symbolic links when
263             performing recursive transfers.
264
265     help    Display help text.
266
267     lcd [path]
268             Change local directory to path.  If path is not specified, then
269             change directory to the local user's home directory.
270
271     lls [ls-options [path]]
272             Display local directory listing of either path or current direc‐
273             tory if path is not specified.  ls-options may contain any flags
274             supported by the local system's ls(1) command.  path may contain
275             glob(7) characters and may match multiple files.
276
277     lmkdir path
278             Create local directory specified by path.
279
280     ln [-s] oldpath newpath
281             Create a link from oldpath to newpath.  If the -s flag is speci‐
282             fied the created link is a symbolic link, otherwise it is a hard
283             link.
284
285     lpwd    Print local working directory.
286
287     ls [-1afhlnrSt] [path]
288             Display a remote directory listing of either path or the current
289             directory if path is not specified.  path may contain glob(7)
290             characters and may match multiple files.
291
292             The following flags are recognized and alter the behaviour of ls
293             accordingly:
294
295             -1      Produce single columnar output.
296
297             -a      List files beginning with a dot (‘.’).
298
299             -f      Do not sort the listing.  The default sort order is lexi‐
300                     cographical.
301
302             -h      When used with a long format option, use unit suffixes:
303                     Byte, Kilobyte, Megabyte, Gigabyte, Terabyte, Petabyte,
304                     and Exabyte in order to reduce the number of digits to
305                     four or fewer using powers of 2 for sizes (K=1024,
306                     M=1048576, etc.).
307
308             -l      Display additional details including permissions and own‐
309                     ership information.
310
311             -n      Produce a long listing with user and group information
312                     presented numerically.
313
314             -r      Reverse the sort order of the listing.
315
316             -S      Sort the listing by file size.
317
318             -t      Sort the listing by last modification time.
319
320     lumask umask
321             Set local umask to umask.
322
323     mkdir path
324             Create remote directory specified by path.
325
326     progress
327             Toggle display of progress meter.
328
329     put [-afpR] local-path [remote-path]
330             Upload local-path and store it on the remote machine.  If the
331             remote path name is not specified, it is given the same name it
332             has on the local machine.  local-path may contain glob(7) charac‐
333             ters and may match multiple files.  If it does and remote-path is
334             specified, then remote-path must specify a directory.
335
336             If the -a flag is specified, then attempt to resume partial
337             transfers of existing files.  Note that resumption assumes that
338             any partial copy of the remote file matches the local copy.  If
339             the local file contents differ from the remote local copy then
340             the resultant file is likely to be corrupt.
341
342             If the -f flag is specified, then a request will be sent to the
343             server to call fsync(2) after the file has been transferred.
344             Note that this is only supported by servers that implement the
345             "fsync@openssh.com" extension.
346
347             If the -p flag is specified, then full file permissions and
348             access times are copied too.
349
350             If the -R flag is specified then directories will be copied
351             recursively.  Note that sftp does not follow symbolic links when
352             performing recursive transfers.
353
354     pwd     Display remote working directory.
355
356     quit    Quit sftp.
357
358     reget [-fpR] remote-path [local-path]
359             Resume download of remote-path.  Equivalent to get with the -a
360             flag set.
361
362     reput [-fpR] local-path [remote-path]
363             Resume upload of local-path.  Equivalent to put with the -a flag
364             set.
365
366     rename oldpath newpath
367             Rename remote file from oldpath to newpath.
368
369     rm path
370             Delete remote file specified by path.
371
372     rmdir path
373             Remove remote directory specified by path.
374
375     symlink oldpath newpath
376             Create a symbolic link from oldpath to newpath.
377
378     version
379             Display the sftp protocol version.
380
381     !command
382             Execute command in local shell.
383
384     !       Escape to local shell.
385
386     ?       Synonym for help.
387

SEE ALSO

389     ftp(1), ls(1), scp(1), ssh(1), ssh-add(1), ssh-keygen(1), ssh_config(5),
390     glob(7), sftp-server(8), sshd(8)
391
392     T. Ylonen and S. Lehtinen, SSH File Transfer Protocol, draft-ietf-secsh-
393     filexfer-00.txt, January 2001, work in progress material.
394
395BSD                            December 31, 2019                           BSD
Impressum