Annotation of src/usr.bin/ssh/sftp.1, Revision 1.86
1.86 ! jmc 1: .\" $OpenBSD: sftp.1,v 1.85 2010/09/22 22:58:51 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.86 ! jmc 25: .Dd $Mdocdate: September 22 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.86 ! jmc 205: .It KexAlgorithms
1.46 jmc 206: .It LogLevel
207: .It MACs
208: .It NoHostAuthenticationForLocalhost
209: .It NumberOfPasswordPrompts
210: .It PasswordAuthentication
1.83 markus 211: .It PKCS11Provider
1.46 jmc 212: .It Port
213: .It PreferredAuthentications
214: .It Protocol
215: .It ProxyCommand
216: .It PubkeyAuthentication
1.63 dtucker 217: .It RekeyLimit
1.46 jmc 218: .It RhostsRSAAuthentication
219: .It RSAAuthentication
1.53 jmc 220: .It SendEnv
1.49 markus 221: .It ServerAliveInterval
222: .It ServerAliveCountMax
1.46 jmc 223: .It StrictHostKeyChecking
1.48 markus 224: .It TCPKeepAlive
1.46 jmc 225: .It UsePrivilegedPort
226: .It User
227: .It UserKnownHostsFile
228: .It VerifyHostKeyDNS
229: .El
1.72 djm 230: .It Fl P Ar port
231: Specifies the port to connect to on the remote host.
1.74 djm 232: .It Fl p
233: Preserves modification times, access times, and modes from the
234: original files transferred.
1.70 djm 235: .It Fl q
236: Quiet mode: disables the progress meter as well as warning and
237: diagnostic messages from
238: .Xr ssh 1 .
1.30 djm 239: .It Fl R Ar num_requests
1.44 jmc 240: Specify how many requests may be outstanding at any one time.
241: Increasing this may slightly improve file transfer speed
242: but will increase memory usage.
1.67 djm 243: The default is 64 outstanding requests.
1.74 djm 244: .It Fl r
245: Recursively copy entire directories when uploading and downloading.
246: Note that
247: .Nm
248: does not follow symbolic links encountered in the tree traversal.
1.26 stevesk 249: .It Fl S Ar program
250: Name of the
251: .Ar program
252: to use for the encrypted connection.
253: The program must understand
254: .Xr ssh 1
255: options.
1.46 jmc 256: .It Fl s Ar subsystem | sftp_server
257: Specifies the SSH2 subsystem or the path for an sftp server
258: on the remote host.
259: A path is useful for using
260: .Nm
261: over protocol version 1, or when the remote
262: .Xr sshd 8
263: does not have an sftp subsystem configured.
264: .It Fl v
265: Raise logging level.
266: This option is also passed to ssh.
1.1 djm 267: .El
268: .Sh INTERACTIVE COMMANDS
1.2 djm 269: Once in interactive mode,
270: .Nm
1.21 itojun 271: understands a set of commands similar to those of
1.1 djm 272: .Xr ftp 1 .
1.60 jaredy 273: Commands are case insensitive.
274: Pathnames that contain spaces must be enclosed in quotes.
275: Any special characters contained within pathnames that are recognized by
276: .Xr glob 3
277: must be escaped with backslashes
278: .Pq Sq \e .
279: .Bl -tag -width Ds
1.22 markus 280: .It Ic bye
1.44 jmc 281: Quit
282: .Nm sftp .
1.3 deraadt 283: .It Ic cd Ar path
1.21 itojun 284: Change remote directory to
1.3 deraadt 285: .Ar path .
286: .It Ic chgrp Ar grp Ar path
1.21 itojun 287: Change group of file
1.5 stevesk 288: .Ar path
289: to
1.1 djm 290: .Ar grp .
1.60 jaredy 291: .Ar path
292: may contain
293: .Xr glob 3
294: characters and may match multiple files.
1.1 djm 295: .Ar grp
1.5 stevesk 296: must be a numeric GID.
1.3 deraadt 297: .It Ic chmod Ar mode Ar path
1.21 itojun 298: Change permissions of file
1.5 stevesk 299: .Ar path
300: to
1.3 deraadt 301: .Ar mode .
1.60 jaredy 302: .Ar path
303: may contain
304: .Xr glob 3
305: characters and may match multiple files.
1.3 deraadt 306: .It Ic chown Ar own Ar path
1.21 itojun 307: Change owner of file
1.5 stevesk 308: .Ar path
309: to
1.1 djm 310: .Ar own .
1.60 jaredy 311: .Ar path
312: may contain
313: .Xr glob 3
314: characters and may match multiple files.
1.1 djm 315: .Ar own
316: must be a numeric UID.
1.65 djm 317: .It Xo Ic df
318: .Op Fl hi
319: .Op Ar path
320: .Xc
321: Display usage information for the filesystem holding the current directory
322: (or
323: .Ar path
324: if specified).
325: If the
326: .Fl h
327: flag is specified, the capacity information will be displayed using
328: "human-readable" suffixes.
329: The
330: .Fl i
331: flag requests display of inode information in addition to capacity information.
332: This command is only supported on servers that implement the
333: .Dq statvfs@openssh.com
334: extension.
1.11 deraadt 335: .It Ic exit
1.44 jmc 336: Quit
337: .Nm sftp .
1.7 djm 338: .It Xo Ic get
1.74 djm 339: .Op Fl Ppr
1.7 djm 340: .Ar remote-path
341: .Op Ar local-path
342: .Xc
1.1 djm 343: Retrieve the
1.5 stevesk 344: .Ar remote-path
1.1 djm 345: and store it on the local machine.
346: If the local
1.21 itojun 347: path name is not specified, it is given the same name it has on the
1.44 jmc 348: remote machine.
1.60 jaredy 349: .Ar remote-path
350: may contain
351: .Xr glob 3
352: characters and may match multiple files.
353: If it does and
354: .Ar local-path
355: is specified, then
356: .Ar local-path
357: must specify a directory.
1.74 djm 358: .Pp
1.76 jmc 359: If either the
1.75 djm 360: .Fl P
1.74 djm 361: or
362: .Fl p
1.60 jaredy 363: flag is specified, then full file permissions and access times are
1.7 djm 364: copied too.
1.74 djm 365: .Pp
366: If the
367: .Fl r
368: flag is specified then directories will be copied recursively.
369: Note that
370: .Nm
371: does not follow symbolic links when performing recursive transfers.
1.11 deraadt 372: .It Ic help
373: Display help text.
1.46 jmc 374: .It Ic lcd Ar path
375: Change local directory to
376: .Ar path .
1.3 deraadt 377: .It Ic lls Op Ar ls-options Op Ar path
1.21 itojun 378: Display local directory listing of either
1.1 djm 379: .Ar path
380: or current directory if
381: .Ar path
1.5 stevesk 382: is not specified.
1.60 jaredy 383: .Ar ls-options
384: may contain any flags supported by the local system's
385: .Xr ls 1
386: command.
387: .Ar path
388: may contain
389: .Xr glob 3
390: characters and may match multiple files.
1.3 deraadt 391: .It Ic lmkdir Ar path
1.1 djm 392: Create local directory specified by
1.3 deraadt 393: .Ar path .
1.12 djm 394: .It Ic ln Ar oldpath Ar newpath
1.21 itojun 395: Create a symbolic link from
1.12 djm 396: .Ar oldpath
397: to
398: .Ar newpath .
1.3 deraadt 399: .It Ic lpwd
400: Print local working directory.
1.36 djm 401: .It Xo Ic ls
1.82 jmc 402: .Op Fl 1afhlnrSt
1.36 djm 403: .Op Ar path
404: .Xc
1.60 jaredy 405: Display a remote directory listing of either
1.1 djm 406: .Ar path
1.60 jaredy 407: or the current directory if
1.5 stevesk 408: .Ar path
1.44 jmc 409: is not specified.
1.60 jaredy 410: .Ar path
411: may contain
412: .Xr glob 3
413: characters and may match multiple files.
414: .Pp
415: The following flags are recognized and alter the behaviour of
416: .Ic ls
417: accordingly:
418: .Bl -tag -width Ds
419: .It Fl 1
420: Produce single columnar output.
421: .It Fl a
422: List files beginning with a dot
423: .Pq Sq \&. .
424: .It Fl f
425: Do not sort the listing.
426: The default sort order is lexicographical.
1.81 djm 427: .It Fl h
428: When used with a long format option, use unit suffixes: Byte, Kilobyte,
429: Megabyte, Gigabyte, Terabyte, Petabyte, and Exabyte in order to reduce
430: the number of digits to four or fewer using powers of 2 for sizes (K=1024,
431: M=1048576, etc.).
1.82 jmc 432: .It Fl l
433: Display additional details including permissions
434: and ownership information.
1.60 jaredy 435: .It Fl n
436: Produce a long listing with user and group information presented
1.56 djm 437: numerically.
1.60 jaredy 438: .It Fl r
439: Reverse the sort order of the listing.
440: .It Fl S
441: Sort the listing by file size.
442: .It Fl t
443: Sort the listing by last modification time.
444: .El
1.3 deraadt 445: .It Ic lumask Ar umask
1.21 itojun 446: Set local umask to
1.3 deraadt 447: .Ar umask .
448: .It Ic mkdir Ar path
1.1 djm 449: Create remote directory specified by
1.3 deraadt 450: .Ar path .
1.40 fgsch 451: .It Ic progress
452: Toggle display of progress meter.
1.7 djm 453: .It Xo Ic put
1.75 djm 454: .Op Fl Ppr
1.7 djm 455: .Ar local-path
1.37 djm 456: .Op Ar remote-path
1.7 djm 457: .Xc
1.1 djm 458: Upload
1.5 stevesk 459: .Ar local-path
1.44 jmc 460: and store it on the remote machine.
461: If the remote path name is not specified, it is given the same name it has
462: on the local machine.
1.60 jaredy 463: .Ar local-path
464: may contain
465: .Xr glob 3
466: characters and may match multiple files.
467: If it does and
468: .Ar remote-path
469: is specified, then
470: .Ar remote-path
471: must specify a directory.
1.74 djm 472: .Pp
473: If ether the
1.7 djm 474: .Fl P
1.74 djm 475: or
476: .Fl p
477: flag is specified, then full file permissions and access times are
1.7 djm 478: copied too.
1.74 djm 479: .Pp
480: If the
481: .Fl r
482: flag is specified then directories will be copied recursively.
483: Note that
484: .Nm
485: does not follow symbolic links when performing recursive transfers.
1.3 deraadt 486: .It Ic pwd
487: Display remote working directory.
488: .It Ic quit
1.44 jmc 489: Quit
490: .Nm sftp .
1.3 deraadt 491: .It Ic rename Ar oldpath Ar newpath
1.1 djm 492: Rename remote file from
493: .Ar oldpath
494: to
1.3 deraadt 495: .Ar newpath .
1.46 jmc 496: .It Ic rm Ar path
497: Delete remote file specified by
498: .Ar path .
1.3 deraadt 499: .It Ic rmdir Ar path
1.1 djm 500: Remove remote directory specified by
1.3 deraadt 501: .Ar path .
1.12 djm 502: .It Ic symlink Ar oldpath Ar newpath
1.21 itojun 503: Create a symbolic link from
1.12 djm 504: .Ar oldpath
505: to
506: .Ar newpath .
1.38 fgsch 507: .It Ic version
508: Display the
509: .Nm
510: protocol version.
1.69 sobrado 511: .It Ic \&! Ns Ar command
1.21 itojun 512: Execute
1.1 djm 513: .Ar command
1.3 deraadt 514: in local shell.
1.45 jmc 515: .It Ic \&!
1.3 deraadt 516: Escape to local shell.
1.45 jmc 517: .It Ic \&?
1.5 stevesk 518: Synonym for help.
1.4 itojun 519: .El
1.1 djm 520: .Sh SEE ALSO
1.46 jmc 521: .Xr ftp 1 ,
1.60 jaredy 522: .Xr ls 1 ,
1.17 markus 523: .Xr scp 1 ,
1.1 djm 524: .Xr ssh 1 ,
525: .Xr ssh-add 1 ,
526: .Xr ssh-keygen 1 ,
1.60 jaredy 527: .Xr glob 3 ,
1.35 stevesk 528: .Xr ssh_config 5 ,
1.17 markus 529: .Xr sftp-server 8 ,
530: .Xr sshd 8
531: .Rs
1.20 deraadt 532: .%A T. Ylonen
533: .%A S. Lehtinen
1.17 markus 534: .%T "SSH File Transfer Protocol"
535: .%N draft-ietf-secsh-filexfer-00.txt
536: .%D January 2001
537: .%O work in progress material
538: .Re