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