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

NAME

4     sftp — OpenSSH secure file transfer
5

SYNOPSIS

7     sftp [-46AaCfNpqrv] [-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      Allows forwarding of ssh-agent(1) to the remote system.  The de‐
42             fault is not to forward an authentication agent.
43
44     -a      Attempt to continue interrupted transfers rather than overwriting
45             existing partial or complete copies of files.  If the partial
46             contents differ from those being transferred, then the resultant
47             file is likely to be corrupt.
48
49     -B buffer_size
50             Specify the size of the buffer that sftp uses when transferring
51             files.  Larger buffers require fewer round trips at the cost of
52             higher memory consumption.  The default is 32768 bytes.
53
54     -b batchfile
55             Batch mode reads a series of commands from an input batchfile in‐
56             stead of stdin.  Since it lacks user interaction, it should be
57             used in conjunction with non-interactive authentication to obvi‐
58             ate the need to enter a password at connection time (see sshd(8)
59             and ssh-keygen(1) for details).
60
61             A batchfile of ‘-’ 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, copy, cp,
64             chmod, chown, chgrp, lpwd, df, symlink, and lmkdir.
65
66             Termination on error can be suppressed on a command by command
67             basis by prefixing the command with a ‘-’ character (for example,
68             -rm /tmp/blah*).  Echo of the command may be suppressed by pre‐
69             fixing the command with a ‘@’ character.  These two prefixes may
70             be combined in any order, for example -@ls /bsd.
71
72     -C      Enables compression (via ssh's -C flag).
73
74     -c cipher
75             Selects the cipher to use for encrypting the data transfers.
76             This option is directly passed to ssh(1).
77
78     -D sftp_server_path
79             Connect directly to a local sftp server (rather than via ssh(1)).
80             This option may be useful in debugging the client and server.
81
82     -F ssh_config
83             Specifies an alternative per-user configuration file for ssh(1).
84             This option is directly passed to ssh(1).
85
86     -f      Requests that files be flushed to disk immediately after trans‐
87             fer.  When uploading files, this feature is only enabled if the
88             server implements the "fsync@openssh.com" extension.
89
90     -i identity_file
91             Selects the file from which the identity (private key) for public
92             key authentication is read.  This option is directly passed to
93             ssh(1).
94
95     -J destination
96             Connect to the target host by first making an sftp connection to
97             the jump host described by destination and then establishing a
98             TCP forwarding to the ultimate destination from there.  Multiple
99             jump hops may be specified separated by comma characters.  This
100             is a shortcut to specify a ProxyJump configuration directive.
101             This option is directly passed to ssh(1).
102
103     -l limit
104             Limits the used bandwidth, specified in Kbit/s.
105
106     -N      Disables quiet mode, e.g. to override the implicit quiet mode set
107             by the -b flag.
108
109     -o ssh_option
110             Can be used to pass options to ssh in the format used in
111             ssh_config(5).  This is useful for specifying options for which
112             there is no separate sftp command-line flag.  For example, to
113             specify an alternate port use: sftp -oPort=24.  For full details
114             of the options listed below, and their possible values, see
115             ssh_config(5).
116
117                   AddressFamily
118                   BatchMode
119                   BindAddress
120                   BindInterface
121                   CanonicalDomains
122                   CanonicalizeFallbackLocal
123                   CanonicalizeHostname
124                   CanonicalizeMaxDots
125                   CanonicalizePermittedCNAMEs
126                   CASignatureAlgorithms
127                   CertificateFile
128                   CheckHostIP
129                   Ciphers
130                   Compression
131                   ConnectionAttempts
132                   ConnectTimeout
133                   ControlMaster
134                   ControlPath
135                   ControlPersist
136                   GlobalKnownHostsFile
137                   GSSAPIAuthentication
138                   GSSAPIDelegateCredentials
139                   HashKnownHosts
140                   Host
141                   HostbasedAcceptedAlgorithms
142                   HostbasedAuthentication
143                   HostKeyAlgorithms
144                   HostKeyAlias
145                   Hostname
146                   IdentitiesOnly
147                   IdentityAgent
148                   IdentityFile
149                   IPQoS
150                   KbdInteractiveAuthentication
151                   KbdInteractiveDevices
152                   KexAlgorithms
153                   KnownHostsCommand
154                   LogLevel
155                   MACs
156                   NoHostAuthenticationForLocalhost
157                   NumberOfPasswordPrompts
158                   PasswordAuthentication
159                   PKCS11Provider
160                   Port
161                   PreferredAuthentications
162                   ProxyCommand
163                   ProxyJump
164                   PubkeyAcceptedAlgorithms
165                   PubkeyAuthentication
166                   RekeyLimit
167                   SendEnv
168                   ServerAliveInterval
169                   ServerAliveCountMax
170                   SetEnv
171                   StrictHostKeyChecking
172                   TCPKeepAlive
173                   UpdateHostKeys
174                   User
175                   UserKnownHostsFile
176                   VerifyHostKeyDNS
177
178     -P port
179             Specifies the port to connect to on the remote host.
180
181     -p      Preserves modification times, access times, and modes from the
182             original files transferred.
183
184     -q      Quiet mode: disables the progress meter as well as warning and
185             diagnostic messages from ssh(1).
186
187     -R num_requests
188             Specify how many requests may be outstanding at any one time.
189             Increasing this may slightly improve file transfer speed but will
190             increase memory usage.  The default is 256 outstanding requests
191             providing for 8MB of outstanding data with a 32KB buffer.
192
193     -r      Recursively copy entire directories when uploading and download‐
194             ing.  Note that sftp does not follow symbolic links encountered
195             in the tree traversal.
196
197     -S program
198             Name of the program to use for the encrypted connection.  The
199             program must understand ssh(1) options.
200
201     -s subsystem | sftp_server
202             Specifies the SSH2 subsystem or the path for an sftp server on
203             the remote host.  A path is useful when the remote sshd(8) does
204             not have an sftp subsystem configured.
205
206     -v      Raise logging level.  This option is also passed to ssh.
207

INTERACTIVE COMMANDS

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

SEE ALSO

412     ftp(1), ls(1), scp(1), ssh(1), ssh-add(1), ssh-keygen(1), ssh_config(5),
413     glob(7), sftp-server(8), sshd(8)
414
415     T. Ylonen and S. Lehtinen, SSH File Transfer Protocol, draft-ietf-secsh-
416     filexfer-00.txt, January 2001, work in progress material.
417
418BSD                             March 31, 2022                             BSD
Impressum