1SFTP(1) BSD General Commands Manual SFTP(1)
2
4 sftp — secure file transfer program
5
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
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 CASignatureAlgorithms
107 CertificateFile
108 ChallengeResponseAuthentication
109 CheckHostIP
110 Ciphers
111 Compression
112 ConnectionAttempts
113 ConnectTimeout
114 ControlMaster
115 ControlPath
116 ControlPersist
117 GlobalKnownHostsFile
118 GSSAPIAuthentication
119 GSSAPIDelegateCredentials
120 HashKnownHosts
121 Host
122 HostbasedAuthentication
123 HostbasedKeyTypes
124 HostKeyAlgorithms
125 HostKeyAlias
126 HostName
127 IdentitiesOnly
128 IdentityAgent
129 IdentityFile
130 IPQoS
131 KbdInteractiveAuthentication
132 KbdInteractiveDevices
133 KexAlgorithms
134 LogLevel
135 MACs
136 NoHostAuthenticationForLocalhost
137 NumberOfPasswordPrompts
138 PasswordAuthentication
139 PKCS11Provider
140 Port
141 PreferredAuthentications
142 ProxyCommand
143 ProxyJump
144 PubkeyAcceptedKeyTypes
145 PubkeyAuthentication
146 RekeyLimit
147 SendEnv
148 ServerAliveInterval
149 ServerAliveCountMax
150 SetEnv
151 StrictHostKeyChecking
152 TCPKeepAlive
153 UpdateHostKeys
154 User
155 UserKnownHostsFile
156 VerifyHostKeyDNS
157
158 -P port
159 Specifies the port to connect to on the remote host.
160
161 -p Preserves modification times, access times, and modes from the
162 original files transferred.
163
164 -q Quiet mode: disables the progress meter as well as warning and
165 diagnostic messages from ssh(1).
166
167 -R num_requests
168 Specify how many requests may be outstanding at any one time.
169 Increasing this may slightly improve file transfer speed but will
170 increase memory usage. The default is 64 outstanding requests.
171
172 -r Recursively copy entire directories when uploading and download‐
173 ing. Note that sftp does not follow symbolic links encountered
174 in the tree traversal.
175
176 -S program
177 Name of the program to use for the encrypted connection. The
178 program must understand ssh(1) options.
179
180 -s subsystem | sftp_server
181 Specifies the SSH2 subsystem or the path for an sftp server on
182 the remote host. A path is useful when the remote sshd(8) does
183 not have an sftp subsystem configured.
184
185 -v Raise logging level. This option is also passed to ssh.
186
188 Once in interactive mode, sftp understands a set of commands similar to
189 those of ftp(1). Commands are case insensitive. Pathnames that contain
190 spaces must be enclosed in quotes. Any special characters contained
191 within pathnames that are recognized by glob(3) must be escaped with
192 backslashes (‘\’).
193
194 bye Quit sftp.
195
196 cd [path]
197 Change remote directory to path. If path is not specified, then
198 change directory to the one the session started in.
199
200 chgrp grp path
201 Change group of file path to grp. path may contain glob(7) char‐
202 acters and may match multiple files. grp must be a numeric GID.
203
204 chmod mode path
205 Change permissions of file path to mode. path may contain
206 glob(7) characters and may match multiple files.
207
208 chown own path
209 Change owner of file path to own. path may contain glob(7) char‐
210 acters and may match multiple files. own must be a numeric UID.
211
212 df [-hi] [path]
213 Display usage information for the filesystem holding the current
214 directory (or path if specified). If the -h flag is specified,
215 the capacity information will be displayed using "human-readable"
216 suffixes. The -i flag requests display of inode information in
217 addition to capacity information. This command is only supported
218 on servers that implement the “statvfs@openssh.com” extension.
219
220 exit Quit sftp.
221
222 get [-afPpr] remote-path [local-path]
223 Retrieve the remote-path and store it on the local machine. If
224 the local path name is not specified, it is given the same name
225 it has on the remote machine. remote-path may contain glob(7)
226 characters and may match multiple files. If it does and
227 local-path is specified, then local-path must specify a direc‐
228 tory.
229
230 If the -a flag is specified, then attempt to resume partial
231 transfers of existing files. Note that resumption assumes that
232 any partial copy of the local file matches the remote copy. If
233 the remote file contents differ from the partial local copy then
234 the resultant file is likely to be corrupt.
235
236 If the -f flag is specified, then fsync(2) will be called after
237 the file transfer has completed to flush the file to disk.
238
239 If either the -P or -p flag is specified, then full file permis‐
240 sions and access times are copied too.
241
242 If the -r flag is specified then directories will be copied
243 recursively. Note that sftp does not follow symbolic links when
244 performing recursive transfers.
245
246 help Display help text.
247
248 lcd [path]
249 Change local directory to path. If path is not specified, then
250 change directory to the local user's home directory.
251
252 lls [ls-options [path]]
253 Display local directory listing of either path or current direc‐
254 tory if path is not specified. ls-options may contain any flags
255 supported by the local system's ls(1) command. path may contain
256 glob(7) characters and may match multiple files.
257
258 lmkdir path
259 Create local directory specified by path.
260
261 ln [-s] oldpath newpath
262 Create a link from oldpath to newpath. If the -s flag is speci‐
263 fied the created link is a symbolic link, otherwise it is a hard
264 link.
265
266 lpwd Print local working directory.
267
268 ls [-1afhlnrSt] [path]
269 Display a remote directory listing of either path or the current
270 directory if path is not specified. path may contain glob(7)
271 characters and may match multiple files.
272
273 The following flags are recognized and alter the behaviour of ls
274 accordingly:
275
276 -1 Produce single columnar output.
277
278 -a List files beginning with a dot (‘.’).
279
280 -f Do not sort the listing. The default sort order is lexi‐
281 cographical.
282
283 -h When used with a long format option, use unit suffixes:
284 Byte, Kilobyte, Megabyte, Gigabyte, Terabyte, Petabyte,
285 and Exabyte in order to reduce the number of digits to
286 four or fewer using powers of 2 for sizes (K=1024,
287 M=1048576, etc.).
288
289 -l Display additional details including permissions and own‐
290 ership information.
291
292 -n Produce a long listing with user and group information
293 presented numerically.
294
295 -r Reverse the sort order of the listing.
296
297 -S Sort the listing by file size.
298
299 -t Sort the listing by last modification time.
300
301 lumask umask
302 Set local umask to umask.
303
304 mkdir path
305 Create remote directory specified by path.
306
307 progress
308 Toggle display of progress meter.
309
310 put [-afPpr] local-path [remote-path]
311 Upload local-path and store it on the remote machine. If the
312 remote path name is not specified, it is given the same name it
313 has on the local machine. local-path may contain glob(7) charac‐
314 ters and may match multiple files. If it does and remote-path is
315 specified, then remote-path must specify a directory.
316
317 If the -a flag is specified, then attempt to resume partial
318 transfers of existing files. Note that resumption assumes that
319 any partial copy of the remote file matches the local copy. If
320 the local file contents differ from the remote local copy then
321 the resultant file is likely to be corrupt.
322
323 If the -f flag is specified, then a request will be sent to the
324 server to call fsync(2) after the file has been transferred.
325 Note that this is only supported by servers that implement the
326 "fsync@openssh.com" extension.
327
328 If either the -P or -p flag is specified, then full file permis‐
329 sions and access times are copied too.
330
331 If the -r flag is specified then directories will be copied
332 recursively. Note that sftp does not follow symbolic links when
333 performing recursive transfers.
334
335 pwd Display remote working directory.
336
337 quit Quit sftp.
338
339 reget [-Ppr] remote-path [local-path]
340 Resume download of remote-path. Equivalent to get with the -a
341 flag set.
342
343 reput [-Ppr] [local-path] remote-path
344 Resume upload of [local-path]. Equivalent to put with the -a
345 flag set.
346
347 rename oldpath newpath
348 Rename remote file from oldpath to newpath.
349
350 rm path
351 Delete remote file specified by path.
352
353 rmdir path
354 Remove remote directory specified by path.
355
356 symlink oldpath newpath
357 Create a symbolic link from oldpath to newpath.
358
359 version
360 Display the sftp protocol version.
361
362 !command
363 Execute command in local shell.
364
365 ! Escape to local shell.
366
367 ? Synonym for help.
368
370 ftp(1), ls(1), scp(1), ssh(1), ssh-add(1), ssh-keygen(1), ssh_config(5),
371 glob(7), sftp-server(8), sshd(8)
372
373 T. Ylonen and S. Lehtinen, SSH File Transfer Protocol, draft-ietf-secsh-
374 filexfer-00.txt, January 2001, work in progress material.
375
376BSD June 20, 2019 BSD