]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - crypto/openssh/sftp.1
THIS BRANCH IS OBSOLETE, PLEASE READ:
[FreeBSD/FreeBSD.git] / crypto / openssh / sftp.1
1 .\" $OpenBSD: sftp.1,v 1.120 2018/09/20 06:58:48 jmc Exp $
2 .\"
3 .\" Copyright (c) 2001 Damien Miller.  All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\"    notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\"    notice, this list of conditions and the following disclaimer in the
12 .\"    documentation and/or other materials provided with the distribution.
13 .\"
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 .\"
25 .Dd $Mdocdate: September 20 2018 $
26 .Dt SFTP 1
27 .Os
28 .Sh NAME
29 .Nm sftp
30 .Nd secure file transfer program
31 .Sh SYNOPSIS
32 .Nm sftp
33 .Op Fl 46aCfpqrv
34 .Op Fl B Ar buffer_size
35 .Op Fl b Ar batchfile
36 .Op Fl c Ar cipher
37 .Op Fl D Ar sftp_server_path
38 .Op Fl F Ar ssh_config
39 .Op Fl i Ar identity_file
40 .Op Fl l Ar limit
41 .Op Fl o Ar ssh_option
42 .Op Fl P Ar port
43 .Op Fl R Ar num_requests
44 .Op Fl S Ar program
45 .Op Fl s Ar subsystem | sftp_server
46 .Ar destination
47 .Sh DESCRIPTION
48 .Nm
49 is a file transfer program, similar to
50 .Xr ftp 1 ,
51 which performs all operations over an encrypted
52 .Xr ssh 1
53 transport.
54 It may also use many features of ssh, such as public key authentication and
55 compression.
56 .Pp
57 The
58 .Ar destination
59 may be specified either as
60 .Sm off
61 .Oo user @ Oc host Op : path
62 .Sm on
63 or as a URI in the form
64 .Sm off
65 .No sftp:// Oo user @ Oc host Oo : port Oc Op / path .
66 .Sm on
67 .Pp
68 If the
69 .Ar destination
70 includes a
71 .Ar path
72 and it is not a directory,
73 .Nm
74 will retrieve files automatically if a non-interactive
75 authentication method is used; otherwise it will do so after
76 successful interactive authentication.
77 .Pp
78 If no
79 .Ar path
80 is specified, or if the
81 .Ar path
82 is a directory,
83 .Nm
84 will log in to the specified
85 .Ar host
86 and enter interactive command mode, changing to the remote directory
87 if one was specified.
88 An optional trailing slash can be used to force the
89 .Ar path
90 to be interpreted as a directory.
91 .Pp
92 Since the destination formats use colon characters to delimit host
93 names from path names or port numbers, IPv6 addresses must be
94 enclosed in square brackets to avoid ambiguity.
95 .Pp
96 The options are as follows:
97 .Bl -tag -width Ds
98 .It Fl 4
99 Forces
100 .Nm
101 to use IPv4 addresses only.
102 .It Fl 6
103 Forces
104 .Nm
105 to use IPv6 addresses only.
106 .It Fl a
107 Attempt to continue interrupted transfers rather than overwriting
108 existing partial or complete copies of files.
109 If the partial contents differ from those being transferred,
110 then the resultant file is likely to be corrupt.
111 .It Fl B Ar buffer_size
112 Specify the size of the buffer that
113 .Nm
114 uses when transferring files.
115 Larger buffers require fewer round trips at the cost of higher
116 memory consumption.
117 The default is 32768 bytes.
118 .It Fl b Ar batchfile
119 Batch mode reads a series of commands from an input
120 .Ar batchfile
121 instead of
122 .Em stdin .
123 Since it lacks user interaction it should be used in conjunction with
124 non-interactive authentication to obviate the need to enter a password
125 at connection time (see
126 .Xr sshd 8
127 and
128 .Xr ssh-keygen 1
129 for details).
130 A
131 .Ar batchfile
132 of
133 .Sq \-
134 may be used to indicate standard input.
135 .Nm
136 will abort if any of the following
137 commands fail:
138 .Ic get , put , reget , reput, rename , ln ,
139 .Ic rm , mkdir , chdir , ls ,
140 .Ic lchdir , chmod , chown ,
141 .Ic chgrp , lpwd , df , symlink ,
142 and
143 .Ic lmkdir .
144 Termination on error can be suppressed on a command by command basis by
145 prefixing the command with a
146 .Sq \-
147 character (for example,
148 .Ic -rm /tmp/blah* ) .
149 .It Fl C
150 Enables compression (via ssh's
151 .Fl C
152 flag).
153 .It Fl c Ar cipher
154 Selects the cipher to use for encrypting the data transfers.
155 This option is directly passed to
156 .Xr ssh 1 .
157 .It Fl D Ar sftp_server_path
158 Connect directly to a local sftp server
159 (rather than via
160 .Xr ssh 1 ) .
161 This option may be useful in debugging the client and server.
162 .It Fl F Ar ssh_config
163 Specifies an alternative
164 per-user configuration file for
165 .Xr ssh 1 .
166 This option is directly passed to
167 .Xr ssh 1 .
168 .It Fl f
169 Requests that files be flushed to disk immediately after transfer.
170 When uploading files, this feature is only enabled if the server
171 implements the "fsync@openssh.com" extension.
172 .It Fl i Ar identity_file
173 Selects the file from which the identity (private key) for public key
174 authentication is read.
175 This option is directly passed to
176 .Xr ssh 1 .
177 .It Fl l Ar limit
178 Limits the used bandwidth, specified in Kbit/s.
179 .It Fl o Ar ssh_option
180 Can be used to pass options to
181 .Nm ssh
182 in the format used in
183 .Xr ssh_config 5 .
184 This is useful for specifying options
185 for which there is no separate
186 .Nm sftp
187 command-line flag.
188 For example, to specify an alternate port use:
189 .Ic sftp -oPort=24 .
190 For full details of the options listed below, and their possible values, see
191 .Xr ssh_config 5 .
192 .Pp
193 .Bl -tag -width Ds -offset indent -compact
194 .It AddressFamily
195 .It BatchMode
196 .It BindAddress
197 .It BindInterface
198 .It CanonicalDomains
199 .It CanonicalizeFallbackLocal
200 .It CanonicalizeHostname
201 .It CanonicalizeMaxDots
202 .It CanonicalizePermittedCNAMEs
203 .It CASignatureAlgorithms
204 .It CertificateFile
205 .It ChallengeResponseAuthentication
206 .It CheckHostIP
207 .It Ciphers
208 .It Compression
209 .It ConnectionAttempts
210 .It ConnectTimeout
211 .It ControlMaster
212 .It ControlPath
213 .It ControlPersist
214 .It GlobalKnownHostsFile
215 .It GSSAPIAuthentication
216 .It GSSAPIDelegateCredentials
217 .It HashKnownHosts
218 .It Host
219 .It HostbasedAuthentication
220 .It HostbasedKeyTypes
221 .It HostKeyAlgorithms
222 .It HostKeyAlias
223 .It HostName
224 .It IdentitiesOnly
225 .It IdentityAgent
226 .It IdentityFile
227 .It IPQoS
228 .It KbdInteractiveAuthentication
229 .It KbdInteractiveDevices
230 .It KexAlgorithms
231 .It LogLevel
232 .It MACs
233 .It NoHostAuthenticationForLocalhost
234 .It NumberOfPasswordPrompts
235 .It PasswordAuthentication
236 .It PKCS11Provider
237 .It Port
238 .It PreferredAuthentications
239 .It ProxyCommand
240 .It ProxyJump
241 .It PubkeyAcceptedKeyTypes
242 .It PubkeyAuthentication
243 .It RekeyLimit
244 .It SendEnv
245 .It ServerAliveInterval
246 .It ServerAliveCountMax
247 .It SetEnv
248 .It StrictHostKeyChecking
249 .It TCPKeepAlive
250 .It UpdateHostKeys
251 .It User
252 .It UserKnownHostsFile
253 .It VerifyHostKeyDNS
254 .El
255 .It Fl P Ar port
256 Specifies the port to connect to on the remote host.
257 .It Fl p
258 Preserves modification times, access times, and modes from the
259 original files transferred.
260 .It Fl q
261 Quiet mode: disables the progress meter as well as warning and
262 diagnostic messages from
263 .Xr ssh 1 .
264 .It Fl R Ar num_requests
265 Specify how many requests may be outstanding at any one time.
266 Increasing this may slightly improve file transfer speed
267 but will increase memory usage.
268 The default is 64 outstanding requests.
269 .It Fl r
270 Recursively copy entire directories when uploading and downloading.
271 Note that
272 .Nm
273 does not follow symbolic links encountered in the tree traversal.
274 .It Fl S Ar program
275 Name of the
276 .Ar program
277 to use for the encrypted connection.
278 The program must understand
279 .Xr ssh 1
280 options.
281 .It Fl s Ar subsystem | sftp_server
282 Specifies the SSH2 subsystem or the path for an sftp server
283 on the remote host.
284 A path is useful when the remote
285 .Xr sshd 8
286 does not have an sftp subsystem configured.
287 .It Fl v
288 Raise logging level.
289 This option is also passed to ssh.
290 .El
291 .Sh INTERACTIVE COMMANDS
292 Once in interactive mode,
293 .Nm
294 understands a set of commands similar to those of
295 .Xr ftp 1 .
296 Commands are case insensitive.
297 Pathnames that contain spaces must be enclosed in quotes.
298 Any special characters contained within pathnames that are recognized by
299 .Xr glob 3
300 must be escaped with backslashes
301 .Pq Sq \e .
302 .Bl -tag -width Ds
303 .It Ic bye
304 Quit
305 .Nm sftp .
306 .It Ic cd Op Ar path
307 Change remote directory to
308 .Ar path .
309 If
310 .Ar path
311 is not specified, then change directory to the one the session started in.
312 .It Ic chgrp Ar grp Ar path
313 Change group of file
314 .Ar path
315 to
316 .Ar grp .
317 .Ar path
318 may contain
319 .Xr glob 7
320 characters and may match multiple files.
321 .Ar grp
322 must be a numeric GID.
323 .It Ic chmod Ar mode Ar path
324 Change permissions of file
325 .Ar path
326 to
327 .Ar mode .
328 .Ar path
329 may contain
330 .Xr glob 7
331 characters and may match multiple files.
332 .It Ic chown Ar own Ar path
333 Change owner of file
334 .Ar path
335 to
336 .Ar own .
337 .Ar path
338 may contain
339 .Xr glob 7
340 characters and may match multiple files.
341 .Ar own
342 must be a numeric UID.
343 .It Xo Ic df
344 .Op Fl hi
345 .Op Ar path
346 .Xc
347 Display usage information for the filesystem holding the current directory
348 (or
349 .Ar path
350 if specified).
351 If the
352 .Fl h
353 flag is specified, the capacity information will be displayed using
354 "human-readable" suffixes.
355 The
356 .Fl i
357 flag requests display of inode information in addition to capacity information.
358 This command is only supported on servers that implement the
359 .Dq statvfs@openssh.com
360 extension.
361 .It Ic exit
362 Quit
363 .Nm sftp .
364 .It Xo Ic get
365 .Op Fl afPpr
366 .Ar remote-path
367 .Op Ar local-path
368 .Xc
369 Retrieve the
370 .Ar remote-path
371 and store it on the local machine.
372 If the local
373 path name is not specified, it is given the same name it has on the
374 remote machine.
375 .Ar remote-path
376 may contain
377 .Xr glob 7
378 characters and may match multiple files.
379 If it does and
380 .Ar local-path
381 is specified, then
382 .Ar local-path
383 must specify a directory.
384 .Pp
385 If the
386 .Fl a
387 flag is specified, then attempt to resume partial transfers of existing files.
388 Note that resumption assumes that any partial copy of the local file matches
389 the remote copy.
390 If the remote file contents differ from the partial local copy then the
391 resultant file is likely to be corrupt.
392 .Pp
393 If the
394 .Fl f
395 flag is specified, then
396 .Xr fsync 2
397 will be called after the file transfer has completed to flush the file
398 to disk.
399 .Pp
400 If either the
401 .Fl P
402 or
403 .Fl p
404 flag is specified, then full file permissions and access times are
405 copied too.
406 .Pp
407 If the
408 .Fl r
409 flag is specified then directories will be copied recursively.
410 Note that
411 .Nm
412 does not follow symbolic links when performing recursive transfers.
413 .It Ic help
414 Display help text.
415 .It Ic lcd Op Ar path
416 Change local directory to
417 .Ar path .
418 If
419 .Ar path
420 is not specified, then change directory to the local user's home directory.
421 .It Ic lls Op Ar ls-options Op Ar path
422 Display local directory listing of either
423 .Ar path
424 or current directory if
425 .Ar path
426 is not specified.
427 .Ar ls-options
428 may contain any flags supported by the local system's
429 .Xr ls 1
430 command.
431 .Ar path
432 may contain
433 .Xr glob 7
434 characters and may match multiple files.
435 .It Ic lmkdir Ar path
436 Create local directory specified by
437 .Ar path .
438 .It Xo Ic ln
439 .Op Fl s
440 .Ar oldpath
441 .Ar newpath
442 .Xc
443 Create a link from
444 .Ar oldpath
445 to
446 .Ar newpath .
447 If the
448 .Fl s
449 flag is specified the created link is a symbolic link, otherwise it is
450 a hard link.
451 .It Ic lpwd
452 Print local working directory.
453 .It Xo Ic ls
454 .Op Fl 1afhlnrSt
455 .Op Ar path
456 .Xc
457 Display a remote directory listing of either
458 .Ar path
459 or the current directory if
460 .Ar path
461 is not specified.
462 .Ar path
463 may contain
464 .Xr glob 7
465 characters and may match multiple files.
466 .Pp
467 The following flags are recognized and alter the behaviour of
468 .Ic ls
469 accordingly:
470 .Bl -tag -width Ds
471 .It Fl 1
472 Produce single columnar output.
473 .It Fl a
474 List files beginning with a dot
475 .Pq Sq \&. .
476 .It Fl f
477 Do not sort the listing.
478 The default sort order is lexicographical.
479 .It Fl h
480 When used with a long format option, use unit suffixes: Byte, Kilobyte,
481 Megabyte, Gigabyte, Terabyte, Petabyte, and Exabyte in order to reduce
482 the number of digits to four or fewer using powers of 2 for sizes (K=1024,
483 M=1048576, etc.).
484 .It Fl l
485 Display additional details including permissions
486 and ownership information.
487 .It Fl n
488 Produce a long listing with user and group information presented
489 numerically.
490 .It Fl r
491 Reverse the sort order of the listing.
492 .It Fl S
493 Sort the listing by file size.
494 .It Fl t
495 Sort the listing by last modification time.
496 .El
497 .It Ic lumask Ar umask
498 Set local umask to
499 .Ar umask .
500 .It Ic mkdir Ar path
501 Create remote directory specified by
502 .Ar path .
503 .It Ic progress
504 Toggle display of progress meter.
505 .It Xo Ic put
506 .Op Fl afPpr
507 .Ar local-path
508 .Op Ar remote-path
509 .Xc
510 Upload
511 .Ar local-path
512 and store it on the remote machine.
513 If the remote path name is not specified, it is given the same name it has
514 on the local machine.
515 .Ar local-path
516 may contain
517 .Xr glob 7
518 characters and may match multiple files.
519 If it does and
520 .Ar remote-path
521 is specified, then
522 .Ar remote-path
523 must specify a directory.
524 .Pp
525 If the
526 .Fl a
527 flag is specified, then attempt to resume partial
528 transfers of existing files.
529 Note that resumption assumes that any partial copy of the remote file
530 matches the local copy.
531 If the local file contents differ from the remote local copy then
532 the resultant file is likely to be corrupt.
533 .Pp
534 If the
535 .Fl f
536 flag is specified, then a request will be sent to the server to call
537 .Xr fsync 2
538 after the file has been transferred.
539 Note that this is only supported by servers that implement
540 the "fsync@openssh.com" extension.
541 .Pp
542 If either the
543 .Fl P
544 or
545 .Fl p
546 flag is specified, then full file permissions and access times are
547 copied too.
548 .Pp
549 If the
550 .Fl r
551 flag is specified then directories will be copied recursively.
552 Note that
553 .Nm
554 does not follow symbolic links when performing recursive transfers.
555 .It Ic pwd
556 Display remote working directory.
557 .It Ic quit
558 Quit
559 .Nm sftp .
560 .It Xo Ic reget
561 .Op Fl Ppr
562 .Ar remote-path
563 .Op Ar local-path
564 .Xc
565 Resume download of
566 .Ar remote-path .
567 Equivalent to
568 .Ic get
569 with the
570 .Fl a
571 flag set.
572 .It Xo Ic reput
573 .Op Fl Ppr
574 .Op Ar local-path
575 .Ar remote-path
576 .Xc
577 Resume upload of
578 .Op Ar local-path .
579 Equivalent to
580 .Ic put
581 with the
582 .Fl a
583 flag set.
584 .It Ic rename Ar oldpath Ar newpath
585 Rename remote file from
586 .Ar oldpath
587 to
588 .Ar newpath .
589 .It Ic rm Ar path
590 Delete remote file specified by
591 .Ar path .
592 .It Ic rmdir Ar path
593 Remove remote directory specified by
594 .Ar path .
595 .It Ic symlink Ar oldpath Ar newpath
596 Create a symbolic link from
597 .Ar oldpath
598 to
599 .Ar newpath .
600 .It Ic version
601 Display the
602 .Nm
603 protocol version.
604 .It Ic \&! Ns Ar command
605 Execute
606 .Ar command
607 in local shell.
608 .It Ic \&!
609 Escape to local shell.
610 .It Ic \&?
611 Synonym for help.
612 .El
613 .Sh SEE ALSO
614 .Xr ftp 1 ,
615 .Xr ls 1 ,
616 .Xr scp 1 ,
617 .Xr ssh 1 ,
618 .Xr ssh-add 1 ,
619 .Xr ssh-keygen 1 ,
620 .Xr ssh_config 5 ,
621 .Xr glob 7 ,
622 .Xr sftp-server 8 ,
623 .Xr sshd 8
624 .Rs
625 .%A T. Ylonen
626 .%A S. Lehtinen
627 .%T "SSH File Transfer Protocol"
628 .%N draft-ietf-secsh-filexfer-00.txt
629 .%D January 2001
630 .%O work in progress material
631 .Re