1SFTP(1)                   BSD General Commands Manual                  SFTP(1)
2

NAME

4     sftp — secure file transfer program
5

SYNOPSIS

7     sftp [-1246Cpqrv] [-B buffer_size] [-b batchfile] [-c cipher]
8          [-D sftp_server_path] [-F ssh_config] [-i identity_file]
9          [-o ssh_option] [-P port] [-R num_requests] [-S program]
10          [-s subsystem | sftp_server] host
11     sftp [user@]host[:file ...]
12     sftp [user@]host[:dir[/]]
13     sftp -b batchfile [user@]host
14

DESCRIPTION

16     sftp is an interactive file transfer program, similar to ftp(1), which
17     performs all operations over an encrypted ssh(1) transport.  It may also
18     use many features of ssh, such as public key authentication and compres‐
19     sion.  sftp connects and logs into the specified host, then enters an
20     interactive command mode.
21
22     The second usage format will retrieve files automatically if a non-inter‐
23     active authentication method is used; otherwise it will do so after suc‐
24     cessful interactive authentication.
25
26     The third usage format allows sftp to start in a remote directory.
27
28     The final usage format allows for automated sessions using the -b option.
29     In such cases, it is necessary to configure non-interactive authentica‐
30     tion to obviate the need to enter a password at connection time (see
31     sshd(8) and ssh-keygen(1) for details).  The options are as follows:
32
33     -1      Specify the use of protocol version 1.
34
35     -2      Specify the use of protocol version 2.
36
37     -4      Forces sftp to use IPv4 addresses only.
38
39     -6      Forces sftp to use IPv6 addresses only.
40
41     -B buffer_size
42             Specify the size of the buffer that sftp uses when transferring
43             files.  Larger buffers require fewer round trips at the cost of
44             higher memory consumption.  The default is 32768 bytes.
45
46     -b batchfile
47             Batch mode reads a series of commands from an input batchfile
48             instead of stdin.  Since it lacks user interaction it should be
49             used in conjunction with non-interactive authentication.  A
50             batchfile of ‘-’ may be used to indicate standard input.  sftp
51             will abort if any of the following commands fail: get, put,
52             rename, ln, rm, mkdir, chdir, ls, lchdir, chmod, chown, chgrp,
53             lpwd, df, and lmkdir.  Termination on error can be suppressed on
54             a command by command basis by prefixing the command with a ‘-’
55             character (for example, -rm /tmp/blah*).
56
57     -C      Enables compression (via ssh's -C flag).
58
59     -c cipher
60             Selects the cipher to use for encrypting the data transfers.
61             This option is directly passed to ssh(1).
62
63     -D sftp_server_path
64             Connect directly to a local sftp server (rather than via ssh(1)).
65             This option may be useful in debugging the client and server.
66
67     -F ssh_config
68             Specifies an alternative per-user configuration file for ssh(1).
69             This option is directly passed to ssh(1).
70
71     -i identity_file
72             Selects the file from which the identity (private key) for public
73             key authentication is read.  This option is directly passed to
74             ssh(1).
75
76     -o ssh_option
77             Can be used to pass options to ssh in the format used in
78             ssh_config(5).  This is useful for specifying options for which
79             there is no separate sftp command-line flag.  For example, to
80             specify an alternate port use: sftp -oPort=24.  For full details
81             of the options listed below, and their possible values, see
82             ssh_config(5).
83
84                   AddressFamily
85                   BatchMode
86                   BindAddress
87                   ChallengeResponseAuthentication
88                   CheckHostIP
89                   Cipher
90                   Ciphers
91                   Compression
92                   CompressionLevel
93                   ConnectionAttempts
94                   ConnectTimeout
95                   ControlMaster
96                   ControlPath
97                   GlobalKnownHostsFile
98                   GSSAPIAuthentication
99                   GSSAPIDelegateCredentials
100                   HashKnownHosts
101                   Host
102                   HostbasedAuthentication
103                   HostKeyAlgorithms
104                   HostKeyAlias
105                   HostName
106                   IdentityFile
107                   IdentitiesOnly
108                   KbdInteractiveDevices
109                   LogLevel
110                   MACs
111                   NoHostAuthenticationForLocalhost
112                   NumberOfPasswordPrompts
113                   PasswordAuthentication
114                   PKCS11Provider
115                   Port
116                   PreferredAuthentications
117                   Protocol
118                   ProxyCommand
119                   PubkeyAuthentication
120                   RekeyLimit
121                   RhostsRSAAuthentication
122                   RSAAuthentication
123                   SendEnv
124                   ServerAliveInterval
125                   ServerAliveCountMax
126                   StrictHostKeyChecking
127                   TCPKeepAlive
128                   UsePrivilegedPort
129                   User
130                   UserKnownHostsFile
131                   VerifyHostKeyDNS
132
133     -P port
134             Specifies the port to connect to on the remote host.
135
136     -p      Preserves modification times, access times, and modes from the
137             original files transferred.
138
139     -q      Quiet mode: disables the progress meter as well as warning and
140             diagnostic messages from ssh(1).
141
142     -R num_requests
143             Specify how many requests may be outstanding at any one time.
144             Increasing this may slightly improve file transfer speed but will
145             increase memory usage.  The default is 64 outstanding requests.
146
147     -r      Recursively copy entire directories when uploading and download‐
148             ing.  Note that sftp does not follow symbolic links encountered
149             in the tree traversal.
150
151     -S program
152             Name of the program to use for the encrypted connection.  The
153             program must understand ssh(1) options.
154
155     -s subsystem | sftp_server
156             Specifies the SSH2 subsystem or the path for an sftp server on
157             the remote host.  A path is useful for using sftp over protocol
158             version 1, or when the remote sshd(8) does not have an sftp sub‐
159             system configured.
160
161     -v      Raise logging level.  This option is also passed to ssh.
162

INTERACTIVE COMMANDS

164     Once in interactive mode, sftp understands a set of commands similar to
165     those of ftp(1).  Commands are case insensitive.  Pathnames that contain
166     spaces must be enclosed in quotes.  Any special characters contained
167     within pathnames that are recognized by glob(3) must be escaped with
168     backslashes (‘\’).
169
170     bye     Quit sftp.
171
172     cd path
173             Change remote directory to path.
174
175     chgrp grp path
176             Change group of file path to grp.  path may contain glob(3) char‐
177             acters and may match multiple files.  grp must be a numeric GID.
178
179     chmod mode path
180             Change permissions of file path to mode.  path may contain
181             glob(3) characters and may match multiple files.
182
183     chown own path
184             Change owner of file path to own.  path may contain glob(3) char‐
185             acters and may match multiple files.  own must be a numeric UID.
186
187     df [-hi] [path]
188             Display usage information for the filesystem holding the current
189             directory (or path if specified).  If the -h flag is specified,
190             the capacity information will be displayed using "human-readable"
191             suffixes.  The -i flag requests display of inode information in
192             addition to capacity information.  This command is only supported
193             on servers that implement the “statvfs@openssh.com” extension.
194
195     exit    Quit sftp.
196
197     get [-Ppr] remote-path [local-path]
198             Retrieve the remote-path and store it on the local machine.  If
199             the local path name is not specified, it is given the same name
200             it has on the remote machine.  remote-path may contain glob(3)
201             characters and may match multiple files.  If it does and
202             local-path is specified, then local-path must specify a direc‐
203             tory.
204
205             If either the -P or -p flag is specified, then full file permis‐
206             sions and access times are copied too.
207
208             If the -r flag is specified then directories will be copied
209             recursively.  Note that sftp does not follow symbolic links when
210             performing recursive transfers.
211
212     help    Display help text.
213
214     lcd path
215             Change local directory to path.
216
217     lls [ls-options [path]]
218             Display local directory listing of either path or current direc‐
219             tory if path is not specified.  ls-options may contain any flags
220             supported by the local system's ls(1) command.  path may contain
221             glob(3) characters and may match multiple files.
222
223     lmkdir path
224             Create local directory specified by path.
225
226     ln oldpath newpath
227             Create a symbolic link from oldpath to newpath.
228
229     lpwd    Print local working directory.
230
231     ls [-1afhlnrSt] [path]
232             Display a remote directory listing of either path or the current
233             directory if path is not specified.  path may contain glob(3)
234             characters and may match multiple files.
235
236             The following flags are recognized and alter the behaviour of ls
237             accordingly:
238
239             -1      Produce single columnar output.
240
241             -a      List files beginning with a dot (‘.’).
242
243             -f      Do not sort the listing.  The default sort order is lexi‐
244                     cographical.
245
246             -h      When used with a long format option, use unit suffixes:
247                     Byte, Kilobyte, Megabyte, Gigabyte, Terabyte, Petabyte,
248                     and Exabyte in order to reduce the number of digits to
249                     four or fewer using powers of 2 for sizes (K=1024,
250                     M=1048576, etc.).
251
252             -l      Display additional details including permissions and own‐
253                     ership information.
254
255             -n      Produce a long listing with user and group information
256                     presented numerically.
257
258             -r      Reverse the sort order of the listing.
259
260             -S      Sort the listing by file size.
261
262             -t      Sort the listing by last modification time.
263
264     lumask umask
265             Set local umask to umask.
266
267     mkdir path
268             Create remote directory specified by path.
269
270     progress
271             Toggle display of progress meter.
272
273     put [-Ppr] local-path [remote-path]
274             Upload local-path and store it on the remote machine.  If the
275             remote path name is not specified, it is given the same name it
276             has on the local machine.  local-path may contain glob(3) charac‐
277             ters and may match multiple files.  If it does and remote-path is
278             specified, then remote-path must specify a directory.
279
280             If ether the -P or -p flag is specified, then full file permis‐
281             sions and access times are copied too.
282
283             If the -r flag is specified then directories will be copied
284             recursively.  Note that sftp does not follow symbolic links when
285             performing recursive transfers.
286
287     pwd     Display remote working directory.
288
289     quit    Quit sftp.
290
291     rename oldpath newpath
292             Rename remote file from oldpath to newpath.
293
294     rm path
295             Delete remote file specified by path.
296
297     rmdir path
298             Remove remote directory specified by path.
299
300     symlink oldpath newpath
301             Create a symbolic link from oldpath to newpath.
302
303     version
304             Display the sftp protocol version.
305
306     !command
307             Execute command in local shell.
308
309     !       Escape to local shell.
310
311     ?       Synonym for help.
312

SEE ALSO

314     ftp(1), ls(1), scp(1), ssh(1), ssh-add(1), ssh-keygen(1), glob(3),
315     ssh_config(5), sftp-server(8), sshd(8)
316
317     T. Ylonen and S. Lehtinen, SSH File Transfer Protocol, draft-ietf-secsh-
318     filexfer-00.txt, January 2001, work in progress material.
319
320BSD                              June 22, 2019                             BSD
Impressum