blob: fe3e4de32096f0b9b4b04fb061f7b96c7dd3d608 [file] [log] [blame]
Darren Tucker636ca902004-11-05 20:22:00 +11001.\" $OpenBSD: sftp.1,v 1.58 2004/10/07 10:10:24 djm Exp $
Damien Miller33804262001-02-04 23:20:18 +11002.\"
Ben Lindstrom92a2e382001-03-05 06:59:27 +00003.\" Copyright (c) 2001 Damien Miller. All rights reserved.
Damien Miller33804262001-02-04 23:20:18 +11004.\"
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.\"
Ben Lindstrom8ffeacf2001-04-10 02:43:57 +000025.Dd February 4, 2001
Damien Miller33804262001-02-04 23:20:18 +110026.Dt SFTP 1
27.Os
28.Sh NAME
29.Nm sftp
Damien Miller50677922003-05-23 18:44:04 +100030.Nd secure file transfer program
Damien Miller33804262001-02-04 23:20:18 +110031.Sh SYNOPSIS
Damien Millerd6ead282003-05-14 19:30:38 +100032.Nm sftp
Damien Miller495dca32003-04-01 21:42:14 +100033.Bk -words
Darren Tucker1f203942003-10-15 15:50:42 +100034.Op Fl 1Cv
Damien Miller81b6e782002-02-08 22:06:03 +110035.Op Fl B Ar buffer_size
Darren Tucker1f203942003-10-15 15:50:42 +100036.Op Fl b Ar batchfile
Damien Miller81b6e782002-02-08 22:06:03 +110037.Op Fl F Ar ssh_config
Darren Tucker1f203942003-10-15 15:50:42 +100038.Op Fl o Ar ssh_option
39.Op Fl P Ar sftp_server_path
Damien Miller16a13332002-02-13 14:03:56 +110040.Op Fl R Ar num_requests
Ben Lindstrom6a337632001-09-18 05:47:32 +000041.Op Fl S Ar program
Darren Tucker1f203942003-10-15 15:50:42 +100042.Op Fl s Ar subsystem | sftp_server
Ben Lindstrom6a337632001-09-18 05:47:32 +000043.Ar host
Damien Miller495dca32003-04-01 21:42:14 +100044.Ek
Damien Millerd6ead282003-05-14 19:30:38 +100045.Nm sftp
Damien Millerc2b98272003-09-03 12:13:30 +100046.Oo Oo Ar user Ns @ Oc Ns
Damien Miller495dca32003-04-01 21:42:14 +100047.Ar host Ns Oo : Ns Ar file Oo
48.Ar file Oc Oc Oc
Damien Millerd6ead282003-05-14 19:30:38 +100049.Nm sftp
Damien Millerc2b98272003-09-03 12:13:30 +100050.Oo Oo Ar user Ns @ Oc Ns
Damien Miller495dca32003-04-01 21:42:14 +100051.Ar host Ns Oo : Ns Ar dir Ns
52.Oo Ar / Oc Oc Oc
Damien Millerd6ead282003-05-14 19:30:38 +100053.Nm sftp
Damien Millerfb7508e2003-05-14 13:47:07 +100054.Fl b Ar batchfile
Damien Millerc2b98272003-09-03 12:13:30 +100055.Oo Ar user Ns @ Oc Ns Ar host
Damien Miller33804262001-02-04 23:20:18 +110056.Sh DESCRIPTION
57.Nm
58is an interactive file transfer program, similar to
59.Xr ftp 1 ,
60which performs all operations over an encrypted
61.Xr ssh 1
62transport.
63It may also use many features of ssh, such as public key authentication and
64compression.
65.Nm
66connects and logs into the specified
Ben Lindstromaafff9c2001-05-06 03:01:02 +000067.Ar host ,
Damien Miller33804262001-02-04 23:20:18 +110068then enters an interactive command mode.
69.Pp
Ben Lindstrom24643222001-06-25 05:08:11 +000070The second usage format will retrieve files automatically if a non-interactive
Ben Lindstromaafff9c2001-05-06 03:01:02 +000071authentication method is used; otherwise it will do so after
72successful interactive authentication.
Ben Lindstrom63667f62001-04-13 00:00:14 +000073.Pp
Damien Millerfb7508e2003-05-14 13:47:07 +100074The third usage format allows the sftp client to start in a remote directory.
Ben Lindstrom63667f62001-04-13 00:00:14 +000075.Pp
Damien Miller50677922003-05-23 18:44:04 +100076The final usage format allows for automated sessions using the
Damien Millerfb7508e2003-05-14 13:47:07 +100077.Fl b
Damien Miller50677922003-05-23 18:44:04 +100078option.
79In such cases, it is usually necessary to configure public key authentication
80to obviate the need to enter a password at connection time (see
Damien Millerfb7508e2003-05-14 13:47:07 +100081.Xr sshd 8
Damien Millerd6ead282003-05-14 19:30:38 +100082and
Damien Millerfb7508e2003-05-14 13:47:07 +100083.Xr ssh-keygen 1
Damien Miller50677922003-05-23 18:44:04 +100084for details).
Damien Miller33804262001-02-04 23:20:18 +110085The options are as follows:
86.Bl -tag -width Ds
Darren Tucker1f203942003-10-15 15:50:42 +100087.It Fl 1
88Specify the use of protocol version 1.
89.It Fl B Ar buffer_size
90Specify the size of the buffer that
91.Nm
92uses when transferring files.
93Larger buffers require fewer round trips at the cost of higher
94memory consumption.
95The default is 32768 bytes.
Ben Lindstrom562c26b2001-03-07 01:26:48 +000096.It Fl b Ar batchfile
97Batch mode reads a series of commands from an input
Ben Lindstrom283cb822001-03-09 00:09:02 +000098.Ar batchfile
Ben Lindstrom562c26b2001-03-07 01:26:48 +000099instead of
Ben Lindstrom283cb822001-03-09 00:09:02 +0000100.Em stdin .
101Since it lacks user interaction it should be used in conjunction with
Damien Miller86a39682004-01-21 11:00:04 +1100102non-interactive authentication.
Damien Miller44f75c12004-01-21 10:58:47 +1100103A
Damien Miller86a39682004-01-21 11:00:04 +1100104.Ar batchfile
105of
106.Sq \-
Damien Miller44f75c12004-01-21 10:58:47 +1100107may be used to indicate standard input.
Ben Lindstrom283cb822001-03-09 00:09:02 +0000108.Nm
Ben Lindstrom24643222001-06-25 05:08:11 +0000109will abort if any of the following
110commands fail:
Ben Lindstrom3612bda2002-03-05 01:26:38 +0000111.Ic get , put , rename , ln ,
Damien Miller495dca32003-04-01 21:42:14 +1000112.Ic rm , mkdir , chdir , ls ,
Damien Miller956f3fb2003-01-10 21:40:00 +1100113.Ic lchdir , chmod , chown , chgrp , lpwd
Ben Lindstrom562c26b2001-03-07 01:26:48 +0000114and
Ben Lindstrom283cb822001-03-09 00:09:02 +0000115.Ic lmkdir .
Damien Miller495dca32003-04-01 21:42:14 +1000116Termination on error can be suppressed on a command by command basis by
117prefixing the command with a
Damien Miller86a39682004-01-21 11:00:04 +1100118.Sq \-
Damien Miller50677922003-05-23 18:44:04 +1000119character (for example,
120.Ic -rm /tmp/blah* ) .
Darren Tucker1f203942003-10-15 15:50:42 +1000121.It Fl C
122Enables compression (via ssh's
123.Fl C
124flag).
125.It Fl F Ar ssh_config
126Specifies an alternative
127per-user configuration file for
128.Xr ssh 1 .
129This option is directly passed to
130.Xr ssh 1 .
Damien Miller33804262001-02-04 23:20:18 +1100131.It Fl o Ar ssh_option
Ben Lindstrom14c62eb2001-08-15 23:25:46 +0000132Can be used to pass options to
133.Nm ssh
Ben Lindstrom3072aae2002-06-21 01:02:39 +0000134in the format used in
135.Xr ssh_config 5 .
136This is useful for specifying options
Ben Lindstrom14c62eb2001-08-15 23:25:46 +0000137for which there is no separate
138.Nm sftp
Damien Miller50677922003-05-23 18:44:04 +1000139command-line flag.
140For example, to specify an alternate port use:
Ben Lindstrom6a337632001-09-18 05:47:32 +0000141.Ic sftp -oPort=24 .
Darren Tucker1f203942003-10-15 15:50:42 +1000142For full details of the options listed below, and their possible values, see
143.Xr ssh_config 5 .
144.Pp
145.Bl -tag -width Ds -offset indent -compact
146.It AddressFamily
147.It BatchMode
148.It BindAddress
149.It ChallengeResponseAuthentication
150.It CheckHostIP
151.It Cipher
152.It Ciphers
Darren Tucker1f203942003-10-15 15:50:42 +1000153.It Compression
154.It CompressionLevel
155.It ConnectionAttempts
Darren Tucker3d5cbb72004-05-03 09:13:15 +1000156.It ConnectTimeout
Damien Miller0e220db2004-06-15 10:34:08 +1000157.It ControlMaster
158.It ControlPath
Darren Tucker1f203942003-10-15 15:50:42 +1000159.It GlobalKnownHostsFile
160.It GSSAPIAuthentication
161.It GSSAPIDelegateCredentials
162.It Host
163.It HostbasedAuthentication
164.It HostKeyAlgorithms
165.It HostKeyAlias
166.It HostName
167.It IdentityFile
Damien Millerbd394c32004-03-08 23:12:36 +1100168.It IdentitiesOnly
Darren Tucker636ca902004-11-05 20:22:00 +1100169.It KbdInteractiveDevices
Darren Tucker1f203942003-10-15 15:50:42 +1000170.It LogLevel
171.It MACs
172.It NoHostAuthenticationForLocalhost
173.It NumberOfPasswordPrompts
174.It PasswordAuthentication
175.It Port
176.It PreferredAuthentications
177.It Protocol
178.It ProxyCommand
179.It PubkeyAuthentication
Darren Tucker1f203942003-10-15 15:50:42 +1000180.It RhostsRSAAuthentication
181.It RSAAuthentication
Darren Tucker7a6c0662004-05-02 22:14:03 +1000182.It SendEnv
Damien Miller509b0102003-12-17 16:33:10 +1100183.It ServerAliveInterval
184.It ServerAliveCountMax
Darren Tucker1f203942003-10-15 15:50:42 +1000185.It SmartcardDevice
186.It StrictHostKeyChecking
Damien Miller12c150e2003-12-17 16:31:10 +1100187.It TCPKeepAlive
Darren Tucker1f203942003-10-15 15:50:42 +1000188.It UsePrivilegedPort
189.It User
190.It UserKnownHostsFile
191.It VerifyHostKeyDNS
Darren Tucker1f203942003-10-15 15:50:42 +1000192.El
193.It Fl P Ar sftp_server_path
Damien Miller50677922003-05-23 18:44:04 +1000194Connect directly to a local sftp server
Damien Miller81b6e782002-02-08 22:06:03 +1100195(rather than via
Damien Miller50677922003-05-23 18:44:04 +1000196.Xr ssh 1 )
Damien Miller81b6e782002-02-08 22:06:03 +1100197This option may be useful in debugging the client and server.
Damien Miller16a13332002-02-13 14:03:56 +1100198.It Fl R Ar num_requests
Damien Miller50677922003-05-23 18:44:04 +1000199Specify how many requests may be outstanding at any one time.
200Increasing this may slightly improve file transfer speed
201but will increase memory usage.
202The default is 16 outstanding requests.
Ben Lindstrom6a337632001-09-18 05:47:32 +0000203.It Fl S Ar program
204Name of the
205.Ar program
206to use for the encrypted connection.
207The program must understand
208.Xr ssh 1
209options.
Darren Tucker1f203942003-10-15 15:50:42 +1000210.It Fl s Ar subsystem | sftp_server
211Specifies the SSH2 subsystem or the path for an sftp server
212on the remote host.
213A path is useful for using
214.Nm
215over protocol version 1, or when the remote
216.Xr sshd 8
217does not have an sftp subsystem configured.
218.It Fl v
219Raise logging level.
220This option is also passed to ssh.
Damien Miller33804262001-02-04 23:20:18 +1100221.El
222.Sh INTERACTIVE COMMANDS
Damien Millerd7686fd2001-02-10 00:40:03 +1100223Once in interactive mode,
224.Nm
Ben Lindstrom24643222001-06-25 05:08:11 +0000225understands a set of commands similar to those of
Damien Miller33804262001-02-04 23:20:18 +1100226.Xr ftp 1 .
Ben Lindstrom27cb1d02001-02-10 21:59:35 +0000227Commands are case insensitive and pathnames may be enclosed in quotes if they
228contain spaces.
Darren Tucker1f203942003-10-15 15:50:42 +1000229.Bl -tag -width "lmdir path"
Ben Lindstrom59e12492001-08-15 23:22:56 +0000230.It Ic bye
Damien Miller50677922003-05-23 18:44:04 +1000231Quit
232.Nm sftp .
Damien Millerd7686fd2001-02-10 00:40:03 +1100233.It Ic cd Ar path
Ben Lindstrom24643222001-06-25 05:08:11 +0000234Change remote directory to
Damien Millerd7686fd2001-02-10 00:40:03 +1100235.Ar path .
Damien Millerd7686fd2001-02-10 00:40:03 +1100236.It Ic chgrp Ar grp Ar path
Ben Lindstrom24643222001-06-25 05:08:11 +0000237Change group of file
Damien Millerd7686fd2001-02-10 00:40:03 +1100238.Ar path
239to
Damien Miller33804262001-02-04 23:20:18 +1100240.Ar grp .
241.Ar grp
Damien Millerd7686fd2001-02-10 00:40:03 +1100242must be a numeric GID.
243.It Ic chmod Ar mode Ar path
Ben Lindstrom24643222001-06-25 05:08:11 +0000244Change permissions of file
Damien Millerd7686fd2001-02-10 00:40:03 +1100245.Ar path
246to
247.Ar mode .
248.It Ic chown Ar own Ar path
Ben Lindstrom24643222001-06-25 05:08:11 +0000249Change owner of file
Damien Millerd7686fd2001-02-10 00:40:03 +1100250.Ar path
251to
Damien Miller33804262001-02-04 23:20:18 +1100252.Ar own .
253.Ar own
254must be a numeric UID.
Ben Lindstromc9b6eab2001-03-07 01:29:17 +0000255.It Ic exit
Damien Miller50677922003-05-23 18:44:04 +1000256Quit
257.Nm sftp .
Ben Lindstrom9d4f2c82001-02-15 03:22:45 +0000258.It Xo Ic get
259.Op Ar flags
260.Ar remote-path
261.Op Ar local-path
262.Xc
Damien Miller33804262001-02-04 23:20:18 +1100263Retrieve the
Damien Millerd7686fd2001-02-10 00:40:03 +1100264.Ar remote-path
Damien Miller33804262001-02-04 23:20:18 +1100265and store it on the local machine.
266If the local
Ben Lindstrom24643222001-06-25 05:08:11 +0000267path name is not specified, it is given the same name it has on the
Damien Miller50677922003-05-23 18:44:04 +1000268remote machine.
269If the
Ben Lindstrom9d4f2c82001-02-15 03:22:45 +0000270.Fl P
271flag is specified, then the file's full permission and access time are
272copied too.
Ben Lindstromc9b6eab2001-03-07 01:29:17 +0000273.It Ic help
274Display help text.
Darren Tucker1f203942003-10-15 15:50:42 +1000275.It Ic lcd Ar path
276Change local directory to
277.Ar path .
Damien Millerd7686fd2001-02-10 00:40:03 +1100278.It Ic lls Op Ar ls-options Op Ar path
Ben Lindstrom24643222001-06-25 05:08:11 +0000279Display local directory listing of either
Damien Miller33804262001-02-04 23:20:18 +1100280.Ar path
281or current directory if
282.Ar path
Damien Millerd7686fd2001-02-10 00:40:03 +1100283is not specified.
284.It Ic lmkdir Ar path
Damien Miller33804262001-02-04 23:20:18 +1100285Create local directory specified by
Damien Millerd7686fd2001-02-10 00:40:03 +1100286.Ar path .
Damien Miller058316f2001-03-08 10:08:49 +1100287.It Ic ln Ar oldpath Ar newpath
Ben Lindstrom24643222001-06-25 05:08:11 +0000288Create a symbolic link from
Damien Miller058316f2001-03-08 10:08:49 +1100289.Ar oldpath
290to
291.Ar newpath .
Damien Millerd7686fd2001-02-10 00:40:03 +1100292.It Ic lpwd
293Print local working directory.
Damien Millere1a49812002-09-12 09:54:25 +1000294.It Xo Ic ls
295.Op Ar flags
296.Op Ar path
297.Xc
Damien Miller33804262001-02-04 23:20:18 +1100298Display remote directory listing of either
299.Ar path
Damien Millerd7686fd2001-02-10 00:40:03 +1100300or current directory if
Damien Miller33804262001-02-04 23:20:18 +1100301.Ar path
Damien Miller50677922003-05-23 18:44:04 +1000302is not specified.
303If the
Damien Millere1a49812002-09-12 09:54:25 +1000304.Fl l
305flag is specified, then display additional details including permissions
306and ownership information.
Darren Tuckerb357afc2004-06-22 12:31:23 +1000307The
308.Fl n
309flag will produce a long listing with user and group information presented
310numerically.
Darren Tucker15ca6e82004-06-22 13:08:21 +1000311.Pp
312By default,
313.Ic ls
314listings are sorted in lexicographical order.
315This may be changed by specifying the
316.Fl S
317(sort by file size),
318.Fl t
319(sort by last modification time), or
320.Fl f
321(don't sort at all) flags.
322Additionally, the sort order may be reversed using the
323.Fl r
324flag.
Damien Millerd7686fd2001-02-10 00:40:03 +1100325.It Ic lumask Ar umask
Ben Lindstrom24643222001-06-25 05:08:11 +0000326Set local umask to
Damien Millerd7686fd2001-02-10 00:40:03 +1100327.Ar umask .
328.It Ic mkdir Ar path
329Create remote directory specified by
330.Ar path .
Damien Miller62d57f62003-01-10 21:43:24 +1100331.It Ic progress
332Toggle display of progress meter.
Ben Lindstrom9d4f2c82001-02-15 03:22:45 +0000333.It Xo Ic put
334.Op Ar flags
335.Ar local-path
Ben Lindstromd5767812002-12-23 02:23:37 +0000336.Op Ar remote-path
Ben Lindstrom9d4f2c82001-02-15 03:22:45 +0000337.Xc
Damien Miller33804262001-02-04 23:20:18 +1100338Upload
Damien Millerd7686fd2001-02-10 00:40:03 +1100339.Ar local-path
Damien Miller50677922003-05-23 18:44:04 +1000340and store it on the remote machine.
341If the remote path name is not specified, it is given the same name it has
342on the local machine.
343If the
Ben Lindstrom9d4f2c82001-02-15 03:22:45 +0000344.Fl P
345flag is specified, then the file's full permission and access time are
346copied too.
Damien Millerd7686fd2001-02-10 00:40:03 +1100347.It Ic pwd
348Display remote working directory.
Damien Millerd7686fd2001-02-10 00:40:03 +1100349.It Ic quit
Damien Miller50677922003-05-23 18:44:04 +1000350Quit
351.Nm sftp .
Damien Millerd7686fd2001-02-10 00:40:03 +1100352.It Ic rename Ar oldpath Ar newpath
Damien Miller33804262001-02-04 23:20:18 +1100353Rename remote file from
354.Ar oldpath
355to
Damien Millerd7686fd2001-02-10 00:40:03 +1100356.Ar newpath .
Damien Millerd7686fd2001-02-10 00:40:03 +1100357.It Ic rm Ar path
Damien Miller33804262001-02-04 23:20:18 +1100358Delete remote file specified by
Damien Millerd7686fd2001-02-10 00:40:03 +1100359.Ar path .
Darren Tucker1f203942003-10-15 15:50:42 +1000360.It Ic rmdir Ar path
361Remove remote directory specified by
362.Ar path .
Damien Miller058316f2001-03-08 10:08:49 +1100363.It Ic symlink Ar oldpath Ar newpath
Ben Lindstrom24643222001-06-25 05:08:11 +0000364Create a symbolic link from
Damien Miller058316f2001-03-08 10:08:49 +1100365.Ar oldpath
366to
367.Ar newpath .
Damien Miller63421802003-01-08 14:05:23 +1100368.It Ic version
369Display the
370.Nm
371protocol version.
Damien Millerc2b98272003-09-03 12:13:30 +1000372.It Ic \&! Ar command
Ben Lindstrom24643222001-06-25 05:08:11 +0000373Execute
Damien Miller33804262001-02-04 23:20:18 +1100374.Ar command
Damien Millerd7686fd2001-02-10 00:40:03 +1100375in local shell.
Damien Millerc2b98272003-09-03 12:13:30 +1000376.It Ic \&!
Damien Millerd7686fd2001-02-10 00:40:03 +1100377Escape to local shell.
Damien Millerc2b98272003-09-03 12:13:30 +1000378.It Ic \&?
Damien Millerd7686fd2001-02-10 00:40:03 +1100379Synonym for help.
380.El
Damien Miller33804262001-02-04 23:20:18 +1100381.Sh SEE ALSO
Darren Tucker1f203942003-10-15 15:50:42 +1000382.Xr ftp 1 ,
Ben Lindstrom160ec622001-04-22 17:17:46 +0000383.Xr scp 1 ,
Damien Miller33804262001-02-04 23:20:18 +1100384.Xr ssh 1 ,
385.Xr ssh-add 1 ,
386.Xr ssh-keygen 1 ,
Ben Lindstrom3072aae2002-06-21 01:02:39 +0000387.Xr ssh_config 5 ,
Ben Lindstrom160ec622001-04-22 17:17:46 +0000388.Xr sftp-server 8 ,
389.Xr sshd 8
390.Rs
Ben Lindstrom90fd0602001-06-25 04:45:33 +0000391.%A T. Ylonen
392.%A S. Lehtinen
Ben Lindstrom160ec622001-04-22 17:17:46 +0000393.%T "SSH File Transfer Protocol"
394.%N draft-ietf-secsh-filexfer-00.txt
395.%D January 2001
396.%O work in progress material
397.Re