nrelease - fix/improve livecd
[dragonfly.git] / crypto / openssh / sftp.1
blob3b3f2c5a791753b1308ca91da23bc2680a4c9946
1 .\" $OpenBSD: sftp.1,v 1.142 2022/09/19 21:39:16 djm 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 19 2022 $
26 .Dt SFTP 1
27 .Os
28 .Sh NAME
29 .Nm sftp
30 .Nd OpenSSH secure file transfer
31 .Sh SYNOPSIS
32 .Nm sftp
33 .Op Fl 46AaCfNpqrv
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_command
38 .Op Fl F Ar ssh_config
39 .Op Fl i Ar identity_file
40 .Op Fl J Ar destination
41 .Op Fl l Ar limit
42 .Op Fl o Ar ssh_option
43 .Op Fl P Ar port
44 .Op Fl R Ar num_requests
45 .Op Fl S Ar program
46 .Op Fl s Ar subsystem | sftp_server
47 .Ar destination
48 .Sh DESCRIPTION
49 .Nm
50 is a file transfer program, similar to
51 .Xr ftp 1 ,
52 which performs all operations over an encrypted
53 .Xr ssh 1
54 transport.
55 It may also use many features of ssh, such as public key authentication and
56 compression.
57 .Pp
58 The
59 .Ar destination
60 may be specified either as
61 .Sm off
62 .Oo user @ Oc host Op : path
63 .Sm on
64 or as a URI in the form
65 .Sm off
66 .No sftp:// Oo user @ Oc host Oo : port Oc Op / path .
67 .Sm on
68 .Pp
69 If the
70 .Ar destination
71 includes a
72 .Ar path
73 and it is not a directory,
74 .Nm
75 will retrieve files automatically if a non-interactive
76 authentication method is used; otherwise it will do so after
77 successful interactive authentication.
78 .Pp
79 If no
80 .Ar path
81 is specified, or if the
82 .Ar path
83 is a directory,
84 .Nm
85 will log in to the specified
86 .Ar host
87 and enter interactive command mode, changing to the remote directory
88 if one was specified.
89 An optional trailing slash can be used to force the
90 .Ar path
91 to be interpreted as a directory.
92 .Pp
93 Since the destination formats use colon characters to delimit host
94 names from path names or port numbers, IPv6 addresses must be
95 enclosed in square brackets to avoid ambiguity.
96 .Pp
97 The options are as follows:
98 .Bl -tag -width Ds
99 .It Fl 4
100 Forces
102 to use IPv4 addresses only.
103 .It Fl 6
104 Forces
106 to use IPv6 addresses only.
107 .It Fl A
108 Allows forwarding of
109 .Xr ssh-agent 1
110 to the remote system.
111 The default is not to forward an authentication agent.
112 .It Fl a
113 Attempt to continue interrupted transfers rather than overwriting
114 existing partial or complete copies of files.
115 If the partial contents differ from those being transferred,
116 then the resultant file is likely to be corrupt.
117 .It Fl B Ar buffer_size
118 Specify the size of the buffer that
120 uses when transferring files.
121 Larger buffers require fewer round trips at the cost of higher
122 memory consumption.
123 The default is 32768 bytes.
124 .It Fl b Ar batchfile
125 Batch mode reads a series of commands from an input
126 .Ar batchfile
127 instead of
128 .Em stdin .
129 Since it lacks user interaction, it should be used in conjunction with
130 non-interactive authentication to obviate the need to enter a password
131 at connection time (see
132 .Xr sshd 8
134 .Xr ssh-keygen 1
135 for details).
138 .Ar batchfile
140 .Sq \-
141 may be used to indicate standard input.
143 will abort if any of the following
144 commands fail:
145 .Ic get , put , reget , reput , rename , ln ,
146 .Ic rm , mkdir , chdir , ls ,
147 .Ic lchdir , copy , cp , chmod , chown ,
148 .Ic chgrp , lpwd , df , symlink ,
150 .Ic lmkdir .
152 Termination on error can be suppressed on a command by command basis by
153 prefixing the command with a
154 .Sq \-
155 character (for example,
156 .Ic -rm /tmp/blah* ) .
157 Echo of the command may be suppressed by prefixing the command with a
158 .Sq @
159 character.
160 These two prefixes may be combined in any order, for example
161 .Ic -@ls /bsd .
162 .It Fl C
163 Enables compression (via ssh's
164 .Fl C
165 flag).
166 .It Fl c Ar cipher
167 Selects the cipher to use for encrypting the data transfers.
168 This option is directly passed to
169 .Xr ssh 1 .
170 .It Fl D Ar sftp_server_command
171 Connect directly to a local sftp server
172 (rather than via
173 .Xr ssh 1 ) .
174 A command and arguments may be specified, for example
175 .Qq /path/sftp-server -el debug3 .
176 This option may be useful in debugging the client and server.
177 .It Fl F Ar ssh_config
178 Specifies an alternative
179 per-user configuration file for
180 .Xr ssh 1 .
181 This option is directly passed to
182 .Xr ssh 1 .
183 .It Fl f
184 Requests that files be flushed to disk immediately after transfer.
185 When uploading files, this feature is only enabled if the server
186 implements the "fsync@openssh.com" extension.
187 .It Fl i Ar identity_file
188 Selects the file from which the identity (private key) for public key
189 authentication is read.
190 This option is directly passed to
191 .Xr ssh 1 .
192 .It Fl J Ar destination
193 Connect to the target host by first making an
195 connection to the jump host described by
196 .Ar destination
197 and then establishing a TCP forwarding to the ultimate destination from
198 there.
199 Multiple jump hops may be specified separated by comma characters.
200 This is a shortcut to specify a
201 .Cm ProxyJump
202 configuration directive.
203 This option is directly passed to
204 .Xr ssh 1 .
205 .It Fl l Ar limit
206 Limits the used bandwidth, specified in Kbit/s.
207 .It Fl N
208 Disables quiet mode, e.g. to override the implicit quiet mode set by the
209 .Fl b
210 flag.
211 .It Fl o Ar ssh_option
212 Can be used to pass options to
213 .Nm ssh
214 in the format used in
215 .Xr ssh_config 5 .
216 This is useful for specifying options
217 for which there is no separate
218 .Nm sftp
219 command-line flag.
220 For example, to specify an alternate port use:
221 .Ic sftp -oPort=24 .
222 For full details of the options listed below, and their possible values, see
223 .Xr ssh_config 5 .
225 .Bl -tag -width Ds -offset indent -compact
226 .It AddressFamily
227 .It BatchMode
228 .It BindAddress
229 .It BindInterface
230 .It CanonicalDomains
231 .It CanonicalizeFallbackLocal
232 .It CanonicalizeHostname
233 .It CanonicalizeMaxDots
234 .It CanonicalizePermittedCNAMEs
235 .It CASignatureAlgorithms
236 .It CertificateFile
237 .It CheckHostIP
238 .It Ciphers
239 .It Compression
240 .It ConnectionAttempts
241 .It ConnectTimeout
242 .It ControlMaster
243 .It ControlPath
244 .It ControlPersist
245 .It GlobalKnownHostsFile
246 .It GSSAPIAuthentication
247 .It GSSAPIDelegateCredentials
248 .It HashKnownHosts
249 .It Host
250 .It HostbasedAcceptedAlgorithms
251 .It HostbasedAuthentication
252 .It HostKeyAlgorithms
253 .It HostKeyAlias
254 .It Hostname
255 .It IdentitiesOnly
256 .It IdentityAgent
257 .It IdentityFile
258 .It IPQoS
259 .It KbdInteractiveAuthentication
260 .It KbdInteractiveDevices
261 .It KexAlgorithms
262 .It KnownHostsCommand
263 .It LogLevel
264 .It MACs
265 .It NoHostAuthenticationForLocalhost
266 .It NumberOfPasswordPrompts
267 .It PasswordAuthentication
268 .It PKCS11Provider
269 .It Port
270 .It PreferredAuthentications
271 .It ProxyCommand
272 .It ProxyJump
273 .It PubkeyAcceptedAlgorithms
274 .It PubkeyAuthentication
275 .It RekeyLimit
276 .It RequiredRSASize
277 .It SendEnv
278 .It ServerAliveInterval
279 .It ServerAliveCountMax
280 .It SetEnv
281 .It StrictHostKeyChecking
282 .It TCPKeepAlive
283 .It UpdateHostKeys
284 .It User
285 .It UserKnownHostsFile
286 .It VerifyHostKeyDNS
288 .It Fl P Ar port
289 Specifies the port to connect to on the remote host.
290 .It Fl p
291 Preserves modification times, access times, and modes from the
292 original files transferred.
293 .It Fl q
294 Quiet mode: disables the progress meter as well as warning and
295 diagnostic messages from
296 .Xr ssh 1 .
297 .It Fl R Ar num_requests
298 Specify how many requests may be outstanding at any one time.
299 Increasing this may slightly improve file transfer speed
300 but will increase memory usage.
301 The default is 64 outstanding requests.
302 .It Fl r
303 Recursively copy entire directories when uploading and downloading.
304 Note that
306 does not follow symbolic links encountered in the tree traversal.
307 .It Fl S Ar program
308 Name of the
309 .Ar program
310 to use for the encrypted connection.
311 The program must understand
312 .Xr ssh 1
313 options.
314 .It Fl s Ar subsystem | sftp_server
315 Specifies the SSH2 subsystem or the path for an sftp server
316 on the remote host.
317 A path is useful when the remote
318 .Xr sshd 8
319 does not have an sftp subsystem configured.
320 .It Fl v
321 Raise logging level.
322 This option is also passed to ssh.
324 .Sh INTERACTIVE COMMANDS
325 Once in interactive mode,
327 understands a set of commands similar to those of
328 .Xr ftp 1 .
329 Commands are case insensitive.
330 Pathnames that contain spaces must be enclosed in quotes.
331 Any special characters contained within pathnames that are recognized by
332 .Xr glob 3
333 must be escaped with backslashes
334 .Pq Sq \e .
335 .Bl -tag -width Ds
336 .It Ic bye
337 Quit
338 .Nm sftp .
339 .It Ic cd Op Ar path
340 Change remote directory to
341 .Ar path .
343 .Ar path
344 is not specified, then change directory to the one the session started in.
345 .It Xo Ic chgrp
346 .Op Fl h
347 .Ar grp
348 .Ar path
350 Change group of file
351 .Ar path
353 .Ar grp .
354 .Ar path
355 may contain
356 .Xr glob 7
357 characters and may match multiple files.
358 .Ar grp
359 must be a numeric GID.
361 If the
362 .Fl h
363 flag is specified, then symlinks will not be followed.
364 Note that this is only supported by servers that implement
365 the "lsetstat@openssh.com" extension.
366 .It Xo Ic chmod
367 .Op Fl h
368 .Ar mode
369 .Ar path
371 Change permissions of file
372 .Ar path
374 .Ar mode .
375 .Ar path
376 may contain
377 .Xr glob 7
378 characters and may match multiple files.
380 If the
381 .Fl h
382 flag is specified, then symlinks will not be followed.
383 Note that this is only supported by servers that implement
384 the "lsetstat@openssh.com" extension.
385 .It Xo Ic chown
386 .Op Fl h
387 .Ar own
388 .Ar path
390 Change owner of file
391 .Ar path
393 .Ar own .
394 .Ar path
395 may contain
396 .Xr glob 7
397 characters and may match multiple files.
398 .Ar own
399 must be a numeric UID.
401 If the
402 .Fl h
403 flag is specified, then symlinks will not be followed.
404 Note that this is only supported by servers that implement
405 the "lsetstat@openssh.com" extension.
406 .It Ic copy Ar oldpath Ar newpath
407 Copy remote file from
408 .Ar oldpath
410 .Ar newpath .
412 Note that this is only supported by servers that implement the "copy-data"
413 extension.
414 .It Ic cp Ar oldpath Ar newpath
415 Alias to
416 .Ic copy
417 command.
418 .It Xo Ic df
419 .Op Fl hi
420 .Op Ar path
422 Display usage information for the filesystem holding the current directory
424 .Ar path
425 if specified).
426 If the
427 .Fl h
428 flag is specified, the capacity information will be displayed using
429 "human-readable" suffixes.
431 .Fl i
432 flag requests display of inode information in addition to capacity information.
433 This command is only supported on servers that implement the
434 .Dq statvfs@openssh.com
435 extension.
436 .It Ic exit
437 Quit
438 .Nm sftp .
439 .It Xo Ic get
440 .Op Fl afpR
441 .Ar remote-path
442 .Op Ar local-path
444 Retrieve the
445 .Ar remote-path
446 and store it on the local machine.
447 If the local
448 path name is not specified, it is given the same name it has on the
449 remote machine.
450 .Ar remote-path
451 may contain
452 .Xr glob 7
453 characters and may match multiple files.
454 If it does and
455 .Ar local-path
456 is specified, then
457 .Ar local-path
458 must specify a directory.
460 If the
461 .Fl a
462 flag is specified, then attempt to resume partial transfers of existing files.
463 Note that resumption assumes that any partial copy of the local file matches
464 the remote copy.
465 If the remote file contents differ from the partial local copy then the
466 resultant file is likely to be corrupt.
468 If the
469 .Fl f
470 flag is specified, then
471 .Xr fsync 2
472 will be called after the file transfer has completed to flush the file
473 to disk.
475 If the
476 .Fl p
477 .\" undocumented redundant alias
478 .\" or
479 .\" .Fl P
480 flag is specified, then full file permissions and access times are
481 copied too.
483 If the
484 .Fl R
485 .\" undocumented redundant alias
486 .\" or
487 .\" .Fl r
488 flag is specified then directories will be copied recursively.
489 Note that
491 does not follow symbolic links when performing recursive transfers.
492 .It Ic help
493 Display help text.
494 .It Ic lcd Op Ar path
495 Change local directory to
496 .Ar path .
498 .Ar path
499 is not specified, then change directory to the local user's home directory.
500 .It Ic lls Op Ar ls-options Op Ar path
501 Display local directory listing of either
502 .Ar path
503 or current directory if
504 .Ar path
505 is not specified.
506 .Ar ls-options
507 may contain any flags supported by the local system's
508 .Xr ls 1
509 command.
510 .Ar path
511 may contain
512 .Xr glob 7
513 characters and may match multiple files.
514 .It Ic lmkdir Ar path
515 Create local directory specified by
516 .Ar path .
517 .It Xo Ic ln
518 .Op Fl s
519 .Ar oldpath
520 .Ar newpath
522 Create a link from
523 .Ar oldpath
525 .Ar newpath .
526 If the
527 .Fl s
528 flag is specified the created link is a symbolic link, otherwise it is
529 a hard link.
530 .It Ic lpwd
531 Print local working directory.
532 .It Xo Ic ls
533 .Op Fl 1afhlnrSt
534 .Op Ar path
536 Display a remote directory listing of either
537 .Ar path
538 or the current directory if
539 .Ar path
540 is not specified.
541 .Ar path
542 may contain
543 .Xr glob 7
544 characters and may match multiple files.
546 The following flags are recognized and alter the behaviour of
547 .Ic ls
548 accordingly:
549 .Bl -tag -width Ds
550 .It Fl 1
551 Produce single columnar output.
552 .It Fl a
553 List files beginning with a dot
554 .Pq Sq \&. .
555 .It Fl f
556 Do not sort the listing.
557 The default sort order is lexicographical.
558 .It Fl h
559 When used with a long format option, use unit suffixes: Byte, Kilobyte,
560 Megabyte, Gigabyte, Terabyte, Petabyte, and Exabyte in order to reduce
561 the number of digits to four or fewer using powers of 2 for sizes (K=1024,
562 M=1048576, etc.).
563 .It Fl l
564 Display additional details including permissions
565 and ownership information.
566 .It Fl n
567 Produce a long listing with user and group information presented
568 numerically.
569 .It Fl r
570 Reverse the sort order of the listing.
571 .It Fl S
572 Sort the listing by file size.
573 .It Fl t
574 Sort the listing by last modification time.
576 .It Ic lumask Ar umask
577 Set local umask to
578 .Ar umask .
579 .It Ic mkdir Ar path
580 Create remote directory specified by
581 .Ar path .
582 .It Ic progress
583 Toggle display of progress meter.
584 .It Xo Ic put
585 .Op Fl afpR
586 .Ar local-path
587 .Op Ar remote-path
589 Upload
590 .Ar local-path
591 and store it on the remote machine.
592 If the remote path name is not specified, it is given the same name it has
593 on the local machine.
594 .Ar local-path
595 may contain
596 .Xr glob 7
597 characters and may match multiple files.
598 If it does and
599 .Ar remote-path
600 is specified, then
601 .Ar remote-path
602 must specify a directory.
604 If the
605 .Fl a
606 flag is specified, then attempt to resume partial
607 transfers of existing files.
608 Note that resumption assumes that any partial copy of the remote file
609 matches the local copy.
610 If the local file contents differ from the remote local copy then
611 the resultant file is likely to be corrupt.
613 If the
614 .Fl f
615 flag is specified, then a request will be sent to the server to call
616 .Xr fsync 2
617 after the file has been transferred.
618 Note that this is only supported by servers that implement
619 the "fsync@openssh.com" extension.
621 If the
622 .Fl p
623 .\" undocumented redundant alias
624 .\" or
625 .\" .Fl P
626 flag is specified, then full file permissions and access times are
627 copied too.
629 If the
630 .Fl R
631 .\" undocumented redundant alias
632 .\" or
633 .\" .Fl r
634 flag is specified then directories will be copied recursively.
635 Note that
637 does not follow symbolic links when performing recursive transfers.
638 .It Ic pwd
639 Display remote working directory.
640 .It Ic quit
641 Quit
642 .Nm sftp .
643 .It Xo Ic reget
644 .Op Fl fpR
645 .Ar remote-path
646 .Op Ar local-path
648 Resume download of
649 .Ar remote-path .
650 Equivalent to
651 .Ic get
652 with the
653 .Fl a
654 flag set.
655 .It Xo Ic reput
656 .Op Fl fpR
657 .Ar local-path
658 .Op Ar remote-path
660 Resume upload of
661 .Ar local-path .
662 Equivalent to
663 .Ic put
664 with the
665 .Fl a
666 flag set.
667 .It Ic rename Ar oldpath newpath
668 Rename remote file from
669 .Ar oldpath
671 .Ar newpath .
672 .It Ic rm Ar path
673 Delete remote file specified by
674 .Ar path .
675 .It Ic rmdir Ar path
676 Remove remote directory specified by
677 .Ar path .
678 .It Ic symlink Ar oldpath newpath
679 Create a symbolic link from
680 .Ar oldpath
682 .Ar newpath .
683 .It Ic version
684 Display the
686 protocol version.
687 .It Ic \&! Ns Ar command
688 Execute
689 .Ar command
690 in local shell.
691 .It Ic \&!
692 Escape to local shell.
693 .It Ic \&?
694 Synonym for help.
696 .Sh SEE ALSO
697 .Xr ftp 1 ,
698 .Xr ls 1 ,
699 .Xr scp 1 ,
700 .Xr ssh 1 ,
701 .Xr ssh-add 1 ,
702 .Xr ssh-keygen 1 ,
703 .Xr ssh_config 5 ,
704 .Xr glob 7 ,
705 .Xr sftp-server 8 ,
706 .Xr sshd 8
708 .%A T. Ylonen
709 .%A S. Lehtinen
710 .%T "SSH File Transfer Protocol"
711 .%N draft-ietf-secsh-filexfer-00.txt
712 .%D January 2001
713 .%O work in progress material