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