Annotation of src/usr.bin/ssh/sftp.1, Revision 1.94
1.94 ! jmc 1: .\" $OpenBSD: sftp.1,v 1.93 2013/08/06 23:05:01 djm Exp $
1.1 djm 2: .\"
1.9 deraadt 3: .\" Copyright (c) 2001 Damien Miller. All rights reserved.
1.1 djm 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: .\"
1.94 ! jmc 25: .Dd $Mdocdate: August 6 2013 $
1.1 djm 26: .Dt SFTP 1
27: .Os
28: .Sh NAME
29: .Nm sftp
1.44 jmc 30: .Nd secure file transfer program
1.1 djm 31: .Sh SYNOPSIS
1.43 jmc 32: .Nm sftp
1.41 jmc 33: .Bk -words
1.94 ! jmc 34: .Op Fl 1246aCpqrv
1.46 jmc 35: .Op Fl B Ar buffer_size
1.29 markus 36: .Op Fl b Ar batchfile
1.70 djm 37: .Op Fl c Ar cipher
1.72 djm 38: .Op Fl D Ar sftp_server_path
1.46 jmc 39: .Op Fl F Ar ssh_config
1.73 jmc 40: .Op Fl i Ar identity_file
1.85 djm 41: .Op Fl l Ar limit
1.29 markus 42: .Op Fl o Ar ssh_option
1.72 djm 43: .Op Fl P Ar port
1.30 djm 44: .Op Fl R Ar num_requests
1.26 stevesk 45: .Op Fl S Ar program
1.46 jmc 46: .Op Fl s Ar subsystem | sftp_server
1.26 stevesk 47: .Ar host
1.41 jmc 48: .Ek
1.43 jmc 49: .Nm sftp
1.68 djm 50: .Oo Ar user Ns @ Oc Ns
51: .Ar host Ns Op : Ns Ar
1.43 jmc 52: .Nm sftp
1.84 jmc 53: .Oo
54: .Ar user Ns @ Oc Ns
1.41 jmc 55: .Ar host Ns Oo : Ns Ar dir Ns
1.84 jmc 56: .Op Ar /
57: .Oc
1.43 jmc 58: .Nm sftp
1.42 djm 59: .Fl b Ar batchfile
1.45 jmc 60: .Oo Ar user Ns @ Oc Ns Ar host
1.1 djm 61: .Sh DESCRIPTION
62: .Nm
63: is an interactive file transfer program, similar to
64: .Xr ftp 1 ,
65: which performs all operations over an encrypted
66: .Xr ssh 1
67: transport.
68: It may also use many features of ssh, such as public key authentication and
69: compression.
70: .Nm
71: connects and logs into the specified
1.18 stevesk 72: .Ar host ,
1.1 djm 73: then enters an interactive command mode.
1.15 mouring 74: .Pp
1.21 itojun 75: The second usage format will retrieve files automatically if a non-interactive
1.18 stevesk 76: authentication method is used; otherwise it will do so after
77: successful interactive authentication.
1.15 mouring 78: .Pp
1.60 jaredy 79: The third usage format allows
80: .Nm
81: to start in a remote directory.
1.1 djm 82: .Pp
1.44 jmc 83: The final usage format allows for automated sessions using the
1.42 djm 84: .Fl b
1.44 jmc 85: option.
1.62 jmc 86: In such cases, it is necessary to configure non-interactive authentication
1.44 jmc 87: to obviate the need to enter a password at connection time (see
1.42 djm 88: .Xr sshd 8
1.43 jmc 89: and
1.42 djm 90: .Xr ssh-keygen 1
1.44 jmc 91: for details).
1.89 djm 92: .Pp
93: Since some usage formats use colon characters to delimit host names from path
94: names, IPv6 addresses must be enclosed in square brackets to avoid ambiguity.
95: .Pp
1.1 djm 96: The options are as follows:
97: .Bl -tag -width Ds
1.46 jmc 98: .It Fl 1
99: Specify the use of protocol version 1.
1.70 djm 100: .It Fl 2
101: Specify the use of protocol version 2.
102: .It Fl 4
103: Forces
104: .Nm
105: to use IPv4 addresses only.
106: .It Fl 6
107: Forces
108: .Nm
109: to use IPv6 addresses only.
1.94 ! jmc 110: .It Fl a
! 111: Attempt to continue interrupted downloads rather than overwriting existing
! 112: partial or complete copies of files.
! 113: If the remote file contents differ from the partial local copy then the
! 114: resultant file is likely to be corrupt.
1.46 jmc 115: .It Fl B Ar buffer_size
116: Specify the size of the buffer that
117: .Nm
118: uses when transferring files.
119: Larger buffers require fewer round trips at the cost of higher
120: memory consumption.
121: The default is 32768 bytes.
1.10 deraadt 122: .It Fl b Ar batchfile
123: Batch mode reads a series of commands from an input
1.13 stevesk 124: .Ar batchfile
1.10 deraadt 125: instead of
1.13 stevesk 126: .Em stdin .
127: Since it lacks user interaction it should be used in conjunction with
1.51 jmc 128: non-interactive authentication.
1.50 djm 129: A
1.51 jmc 130: .Ar batchfile
131: of
132: .Sq \-
1.50 djm 133: may be used to indicate standard input.
1.13 stevesk 134: .Nm
1.21 itojun 135: will abort if any of the following
136: commands fail:
1.92 djm 137: .Ic get , put , reget , rename , ln ,
1.41 jmc 138: .Ic rm , mkdir , chdir , ls ,
1.66 jmc 139: .Ic lchdir , chmod , chown ,
1.88 djm 140: .Ic chgrp , lpwd , df , symlink ,
1.10 deraadt 141: and
1.13 stevesk 142: .Ic lmkdir .
1.41 jmc 143: Termination on error can be suppressed on a command by command basis by
144: prefixing the command with a
1.51 jmc 145: .Sq \-
1.44 jmc 146: character (for example,
147: .Ic -rm /tmp/blah* ) .
1.71 jmc 148: .It Fl C
149: Enables compression (via ssh's
150: .Fl C
151: flag).
1.70 djm 152: .It Fl c Ar cipher
153: Selects the cipher to use for encrypting the data transfers.
154: This option is directly passed to
155: .Xr ssh 1 .
1.72 djm 156: .It Fl D Ar sftp_server_path
157: Connect directly to a local sftp server
158: (rather than via
159: .Xr ssh 1 ) .
160: This option may be useful in debugging the client and server.
1.46 jmc 161: .It Fl F Ar ssh_config
162: Specifies an alternative
163: per-user configuration file for
164: .Xr ssh 1 .
165: This option is directly passed to
166: .Xr ssh 1 .
1.70 djm 167: .It Fl i Ar identity_file
168: Selects the file from which the identity (private key) for public key
169: authentication is read.
170: This option is directly passed to
171: .Xr ssh 1 .
1.85 djm 172: .It Fl l Ar limit
173: Limits the used bandwidth, specified in Kbit/s.
1.1 djm 174: .It Fl o Ar ssh_option
1.23 stevesk 175: Can be used to pass options to
176: .Nm ssh
1.35 stevesk 177: in the format used in
178: .Xr ssh_config 5 .
179: This is useful for specifying options
1.23 stevesk 180: for which there is no separate
181: .Nm sftp
1.44 jmc 182: command-line flag.
183: For example, to specify an alternate port use:
1.26 stevesk 184: .Ic sftp -oPort=24 .
1.46 jmc 185: For full details of the options listed below, and their possible values, see
186: .Xr ssh_config 5 .
187: .Pp
188: .Bl -tag -width Ds -offset indent -compact
189: .It AddressFamily
190: .It BatchMode
191: .It BindAddress
192: .It ChallengeResponseAuthentication
193: .It CheckHostIP
194: .It Cipher
195: .It Ciphers
196: .It Compression
197: .It CompressionLevel
198: .It ConnectionAttempts
1.54 dtucker 199: .It ConnectTimeout
1.55 djm 200: .It ControlMaster
201: .It ControlPath
1.91 djm 202: .It ControlPersist
1.46 jmc 203: .It GlobalKnownHostsFile
204: .It GSSAPIAuthentication
205: .It GSSAPIDelegateCredentials
1.61 jmc 206: .It HashKnownHosts
1.46 jmc 207: .It Host
208: .It HostbasedAuthentication
209: .It HostKeyAlgorithms
210: .It HostKeyAlias
211: .It HostName
212: .It IdentityFile
1.52 markus 213: .It IdentitiesOnly
1.87 jmc 214: .It IPQoS
1.91 djm 215: .It KbdInteractiveAuthentication
1.58 djm 216: .It KbdInteractiveDevices
1.86 jmc 217: .It KexAlgorithms
1.46 jmc 218: .It LogLevel
219: .It MACs
220: .It NoHostAuthenticationForLocalhost
221: .It NumberOfPasswordPrompts
222: .It PasswordAuthentication
1.83 markus 223: .It PKCS11Provider
1.46 jmc 224: .It Port
225: .It PreferredAuthentications
226: .It Protocol
227: .It ProxyCommand
228: .It PubkeyAuthentication
1.63 dtucker 229: .It RekeyLimit
1.46 jmc 230: .It RhostsRSAAuthentication
231: .It RSAAuthentication
1.53 jmc 232: .It SendEnv
1.49 markus 233: .It ServerAliveInterval
234: .It ServerAliveCountMax
1.46 jmc 235: .It StrictHostKeyChecking
1.48 markus 236: .It TCPKeepAlive
1.46 jmc 237: .It UsePrivilegedPort
238: .It User
239: .It UserKnownHostsFile
240: .It VerifyHostKeyDNS
241: .El
1.72 djm 242: .It Fl P Ar port
243: Specifies the port to connect to on the remote host.
1.74 djm 244: .It Fl p
245: Preserves modification times, access times, and modes from the
246: original files transferred.
1.70 djm 247: .It Fl q
248: Quiet mode: disables the progress meter as well as warning and
249: diagnostic messages from
250: .Xr ssh 1 .
1.30 djm 251: .It Fl R Ar num_requests
1.44 jmc 252: Specify how many requests may be outstanding at any one time.
253: Increasing this may slightly improve file transfer speed
254: but will increase memory usage.
1.67 djm 255: The default is 64 outstanding requests.
1.74 djm 256: .It Fl r
257: Recursively copy entire directories when uploading and downloading.
258: Note that
259: .Nm
260: does not follow symbolic links encountered in the tree traversal.
1.26 stevesk 261: .It Fl S Ar program
262: Name of the
263: .Ar program
264: to use for the encrypted connection.
265: The program must understand
266: .Xr ssh 1
267: options.
1.46 jmc 268: .It Fl s Ar subsystem | sftp_server
269: Specifies the SSH2 subsystem or the path for an sftp server
270: on the remote host.
271: A path is useful for using
272: .Nm
273: over protocol version 1, or when the remote
274: .Xr sshd 8
275: does not have an sftp subsystem configured.
276: .It Fl v
277: Raise logging level.
278: This option is also passed to ssh.
1.1 djm 279: .El
280: .Sh INTERACTIVE COMMANDS
1.2 djm 281: Once in interactive mode,
282: .Nm
1.21 itojun 283: understands a set of commands similar to those of
1.1 djm 284: .Xr ftp 1 .
1.60 jaredy 285: Commands are case insensitive.
286: Pathnames that contain spaces must be enclosed in quotes.
287: Any special characters contained within pathnames that are recognized by
288: .Xr glob 3
289: must be escaped with backslashes
290: .Pq Sq \e .
291: .Bl -tag -width Ds
1.22 markus 292: .It Ic bye
1.44 jmc 293: Quit
294: .Nm sftp .
1.3 deraadt 295: .It Ic cd Ar path
1.21 itojun 296: Change remote directory to
1.3 deraadt 297: .Ar path .
298: .It Ic chgrp Ar grp Ar path
1.21 itojun 299: Change group of file
1.5 stevesk 300: .Ar path
301: to
1.1 djm 302: .Ar grp .
1.60 jaredy 303: .Ar path
304: may contain
305: .Xr glob 3
306: characters and may match multiple files.
1.1 djm 307: .Ar grp
1.5 stevesk 308: must be a numeric GID.
1.3 deraadt 309: .It Ic chmod Ar mode Ar path
1.21 itojun 310: Change permissions of file
1.5 stevesk 311: .Ar path
312: to
1.3 deraadt 313: .Ar mode .
1.60 jaredy 314: .Ar path
315: may contain
316: .Xr glob 3
317: characters and may match multiple files.
1.3 deraadt 318: .It Ic chown Ar own Ar path
1.21 itojun 319: Change owner of file
1.5 stevesk 320: .Ar path
321: to
1.1 djm 322: .Ar own .
1.60 jaredy 323: .Ar path
324: may contain
325: .Xr glob 3
326: characters and may match multiple files.
1.1 djm 327: .Ar own
328: must be a numeric UID.
1.65 djm 329: .It Xo Ic df
330: .Op Fl hi
331: .Op Ar path
332: .Xc
333: Display usage information for the filesystem holding the current directory
334: (or
335: .Ar path
336: if specified).
337: If the
338: .Fl h
339: flag is specified, the capacity information will be displayed using
340: "human-readable" suffixes.
341: The
342: .Fl i
343: flag requests display of inode information in addition to capacity information.
344: This command is only supported on servers that implement the
345: .Dq statvfs@openssh.com
346: extension.
1.11 deraadt 347: .It Ic exit
1.44 jmc 348: Quit
349: .Nm sftp .
1.7 djm 350: .It Xo Ic get
1.92 djm 351: .Op Fl aPpr
1.7 djm 352: .Ar remote-path
353: .Op Ar local-path
354: .Xc
1.1 djm 355: Retrieve the
1.5 stevesk 356: .Ar remote-path
1.1 djm 357: and store it on the local machine.
358: If the local
1.21 itojun 359: path name is not specified, it is given the same name it has on the
1.44 jmc 360: remote machine.
1.60 jaredy 361: .Ar remote-path
362: may contain
363: .Xr glob 3
364: characters and may match multiple files.
365: If it does and
366: .Ar local-path
367: is specified, then
368: .Ar local-path
369: must specify a directory.
1.74 djm 370: .Pp
1.92 djm 371: If the
372: .Fl a
373: flag is specified, then attempt to resume partial transfers of existing files.
374: Note that resumption assumes that any partial copy of the local file matches
375: the remote copy.
1.93 djm 376: If the remote file contents differ from the partial local copy then the
377: resultant file is likely to be corrupt.
1.92 djm 378: .Pp
1.76 jmc 379: If either the
1.75 djm 380: .Fl P
1.74 djm 381: or
382: .Fl p
1.60 jaredy 383: flag is specified, then full file permissions and access times are
1.7 djm 384: copied too.
1.74 djm 385: .Pp
386: If the
387: .Fl r
388: flag is specified then directories will be copied recursively.
389: Note that
390: .Nm
391: does not follow symbolic links when performing recursive transfers.
1.11 deraadt 392: .It Ic help
393: Display help text.
1.46 jmc 394: .It Ic lcd Ar path
395: Change local directory to
396: .Ar path .
1.3 deraadt 397: .It Ic lls Op Ar ls-options Op Ar path
1.21 itojun 398: Display local directory listing of either
1.1 djm 399: .Ar path
400: or current directory if
401: .Ar path
1.5 stevesk 402: is not specified.
1.60 jaredy 403: .Ar ls-options
404: may contain any flags supported by the local system's
405: .Xr ls 1
406: command.
407: .Ar path
408: may contain
409: .Xr glob 3
410: characters and may match multiple files.
1.3 deraadt 411: .It Ic lmkdir Ar path
1.1 djm 412: Create local directory specified by
1.3 deraadt 413: .Ar path .
1.88 djm 414: .It Xo Ic ln
415: .Op Fl s
416: .Ar oldpath
417: .Ar newpath
418: .Xc
419: Create a link from
1.12 djm 420: .Ar oldpath
421: to
422: .Ar newpath .
1.88 djm 423: If the
424: .Fl s
425: flag is specified the created link is a symbolic link, otherwise it is
426: a hard link.
1.3 deraadt 427: .It Ic lpwd
428: Print local working directory.
1.36 djm 429: .It Xo Ic ls
1.82 jmc 430: .Op Fl 1afhlnrSt
1.36 djm 431: .Op Ar path
432: .Xc
1.60 jaredy 433: Display a remote directory listing of either
1.1 djm 434: .Ar path
1.60 jaredy 435: or the current directory if
1.5 stevesk 436: .Ar path
1.44 jmc 437: is not specified.
1.60 jaredy 438: .Ar path
439: may contain
440: .Xr glob 3
441: characters and may match multiple files.
442: .Pp
443: The following flags are recognized and alter the behaviour of
444: .Ic ls
445: accordingly:
446: .Bl -tag -width Ds
447: .It Fl 1
448: Produce single columnar output.
449: .It Fl a
450: List files beginning with a dot
451: .Pq Sq \&. .
452: .It Fl f
453: Do not sort the listing.
454: The default sort order is lexicographical.
1.81 djm 455: .It Fl h
456: When used with a long format option, use unit suffixes: Byte, Kilobyte,
457: Megabyte, Gigabyte, Terabyte, Petabyte, and Exabyte in order to reduce
458: the number of digits to four or fewer using powers of 2 for sizes (K=1024,
459: M=1048576, etc.).
1.82 jmc 460: .It Fl l
461: Display additional details including permissions
462: and ownership information.
1.60 jaredy 463: .It Fl n
464: Produce a long listing with user and group information presented
1.56 djm 465: numerically.
1.60 jaredy 466: .It Fl r
467: Reverse the sort order of the listing.
468: .It Fl S
469: Sort the listing by file size.
470: .It Fl t
471: Sort the listing by last modification time.
472: .El
1.3 deraadt 473: .It Ic lumask Ar umask
1.21 itojun 474: Set local umask to
1.3 deraadt 475: .Ar umask .
476: .It Ic mkdir Ar path
1.1 djm 477: Create remote directory specified by
1.3 deraadt 478: .Ar path .
1.40 fgsch 479: .It Ic progress
480: Toggle display of progress meter.
1.7 djm 481: .It Xo Ic put
1.75 djm 482: .Op Fl Ppr
1.7 djm 483: .Ar local-path
1.37 djm 484: .Op Ar remote-path
1.7 djm 485: .Xc
1.1 djm 486: Upload
1.5 stevesk 487: .Ar local-path
1.44 jmc 488: and store it on the remote machine.
489: If the remote path name is not specified, it is given the same name it has
490: on the local machine.
1.60 jaredy 491: .Ar local-path
492: may contain
493: .Xr glob 3
494: characters and may match multiple files.
495: If it does and
496: .Ar remote-path
497: is specified, then
498: .Ar remote-path
499: must specify a directory.
1.74 djm 500: .Pp
1.90 dtucker 501: If either the
1.7 djm 502: .Fl P
1.74 djm 503: or
504: .Fl p
505: flag is specified, then full file permissions and access times are
1.7 djm 506: copied too.
1.74 djm 507: .Pp
508: If the
509: .Fl r
510: flag is specified then directories will be copied recursively.
511: Note that
512: .Nm
513: does not follow symbolic links when performing recursive transfers.
1.3 deraadt 514: .It Ic pwd
515: Display remote working directory.
516: .It Ic quit
1.44 jmc 517: Quit
518: .Nm sftp .
1.92 djm 519: .It Xo Ic reget
520: .Op Fl Ppr
521: .Ar remote-path
522: .Op Ar local-path
523: .Xc
524: Resume download of
525: .Ar remote-path .
526: Equivalent to
527: .Ic get
528: with the
529: .Fl a
530: flag set.
1.3 deraadt 531: .It Ic rename Ar oldpath Ar newpath
1.1 djm 532: Rename remote file from
533: .Ar oldpath
534: to
1.3 deraadt 535: .Ar newpath .
1.46 jmc 536: .It Ic rm Ar path
537: Delete remote file specified by
538: .Ar path .
1.3 deraadt 539: .It Ic rmdir Ar path
1.1 djm 540: Remove remote directory specified by
1.3 deraadt 541: .Ar path .
1.12 djm 542: .It Ic symlink Ar oldpath Ar newpath
1.21 itojun 543: Create a symbolic link from
1.12 djm 544: .Ar oldpath
545: to
546: .Ar newpath .
1.38 fgsch 547: .It Ic version
548: Display the
549: .Nm
550: protocol version.
1.69 sobrado 551: .It Ic \&! Ns Ar command
1.21 itojun 552: Execute
1.1 djm 553: .Ar command
1.3 deraadt 554: in local shell.
1.45 jmc 555: .It Ic \&!
1.3 deraadt 556: Escape to local shell.
1.45 jmc 557: .It Ic \&?
1.5 stevesk 558: Synonym for help.
1.4 itojun 559: .El
1.1 djm 560: .Sh SEE ALSO
1.46 jmc 561: .Xr ftp 1 ,
1.60 jaredy 562: .Xr ls 1 ,
1.17 markus 563: .Xr scp 1 ,
1.1 djm 564: .Xr ssh 1 ,
565: .Xr ssh-add 1 ,
566: .Xr ssh-keygen 1 ,
1.60 jaredy 567: .Xr glob 3 ,
1.35 stevesk 568: .Xr ssh_config 5 ,
1.17 markus 569: .Xr sftp-server 8 ,
570: .Xr sshd 8
571: .Rs
1.20 deraadt 572: .%A T. Ylonen
573: .%A S. Lehtinen
1.17 markus 574: .%T "SSH File Transfer Protocol"
575: .%N draft-ietf-secsh-filexfer-00.txt
576: .%D January 2001
577: .%O work in progress material
578: .Re