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] [-l limit]
9          [-o ssh_option] [-P port] [-R num_requests] [-S program]
10          [-s subsystem | sftp_server] destination
11

DESCRIPTION

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 fea‐
15     tures of ssh, such as public key authentication and compression.
16
17     The destination may be specified either as [user@]host[:path] or as a URI
18     in the form sftp://[user@]host[:port][/path].
19
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 authentica‐
23     tion.
24
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.
29
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.
33
34     The options are as follows:
35
36     -4      Forces sftp to use IPv4 addresses only.
37
38     -6      Forces sftp to use IPv6 addresses only.
39
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.
44
45     -B buffer_size
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.
49
50     -b batchfile
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 obvi‐
54             ate the need to enter a password at connection time (see sshd(8)
55             and ssh-keygen(1) for details).  A batchfile of ‘-’ may be used
56             to indicate standard input.  sftp will abort if any of the fol‐
57             lowing commands fail: get, put, reget, reput, rename, ln, rm,
58             mkdir, chdir, ls, lchdir, chmod, chown, chgrp, lpwd, df, symlink,
59             and lmkdir.  Termination on error can be suppressed on a command
60             by command basis by prefixing the command with a ‘-’ character
61             (for example, -rm /tmp/blah*).
62
63     -C      Enables compression (via ssh's -C flag).
64
65     -c cipher
66             Selects the cipher to use for encrypting the data transfers.
67             This option is directly passed to ssh(1).
68
69     -D sftp_server_path
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.
72
73     -F ssh_config
74             Specifies an alternative per-user configuration file for ssh(1).
75             This option is directly passed to ssh(1).
76
77     -f      Requests that files be flushed to disk immediately after trans‐
78             fer.  When uploading files, this feature is only enabled if the
79             server implements the "fsync@openssh.com" extension.
80
81     -i identity_file
82             Selects the file from which the identity (private key) for public
83             key authentication is read.  This option is directly passed to
84             ssh(1).
85
86     -l limit
87             Limits the used bandwidth, specified in Kbit/s.
88
89     -o ssh_option
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
95             ssh_config(5).
96
97                   AddressFamily
98                   BatchMode
99                   BindAddress
100                   BindInterface
101                   CanonicalDomains
102                   CanonicalizeFallbackLocal
103                   CanonicalizeHostname
104                   CanonicalizeMaxDots
105                   CanonicalizePermittedCNAMEs
106                   CertificateFile
107                   ChallengeResponseAuthentication
108                   CheckHostIP
109                   Ciphers
110                   Compression
111                   ConnectionAttempts
112                   ConnectTimeout
113                   ControlMaster
114                   ControlPath
115                   ControlPersist
116                   GlobalKnownHostsFile
117                   GSSAPIAuthentication
118                   GSSAPIDelegateCredentials
119                   HashKnownHosts
120                   Host
121                   HostbasedAuthentication
122                   HostbasedKeyTypes
123                   HostKeyAlgorithms
124                   HostKeyAlias
125                   HostName
126                   IdentitiesOnly
127                   IdentityAgent
128                   IdentityFile
129                   IPQoS
130                   KbdInteractiveAuthentication
131                   KbdInteractiveDevices
132                   KexAlgorithms
133                   LogLevel
134                   MACs
135                   NoHostAuthenticationForLocalhost
136                   NumberOfPasswordPrompts
137                   PasswordAuthentication
138                   PKCS11Provider
139                   Port
140                   PreferredAuthentications
141                   ProxyCommand
142                   ProxyJump
143                   PubkeyAcceptedKeyTypes
144                   PubkeyAuthentication
145                   RekeyLimit
146                   SendEnv
147                   ServerAliveInterval
148                   ServerAliveCountMax
149                   SetEnv
150                   StrictHostKeyChecking
151                   TCPKeepAlive
152                   UpdateHostKeys
153                   User
154                   UserKnownHostsFile
155                   VerifyHostKeyDNS
156
157     -P port
158             Specifies the port to connect to on the remote host.
159
160     -p      Preserves modification times, access times, and modes from the
161             original files transferred.
162
163     -q      Quiet mode: disables the progress meter as well as warning and
164             diagnostic messages from ssh(1).
165
166     -R num_requests
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.
170
171     -r      Recursively copy entire directories when uploading and download‐
172             ing.  Note that sftp does not follow symbolic links encountered
173             in the tree traversal.
174
175     -S program
176             Name of the program to use for the encrypted connection.  The
177             program must understand ssh(1) options.
178
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.
183
184     -v      Raise logging level.  This option is also passed to ssh.
185

INTERACTIVE COMMANDS

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

SEE ALSO

369     ftp(1), ls(1), scp(1), ssh(1), ssh-add(1), ssh-keygen(1), ssh_config(5),
370     glob(7), sftp-server(8), sshd(8)
371
372     T. Ylonen and S. Lehtinen, SSH File Transfer Protocol, draft-ietf-secsh-
373     filexfer-00.txt, January 2001, work in progress material.
374
375BSD                            October 26, 2019                            BSD
Impressum