1.\" $NetBSD: sftp.1,v 1.9 2013/11/08 19:18:25 christos Exp $ 2.\" $OpenBSD: sftp.1,v 1.92 2013/07/25 00:56:51 djm Exp $ 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 July 25 2013 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 , reget , 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 Ic df Oo Fl hi Oc Oo Ar path Oc 327Display usage information for the filesystem holding the current directory 328(or 329.Ar path 330if specified). 331If the 332.Fl h 333flag is specified, the capacity information will be displayed using 334"human-readable" suffixes. 335The 336.Fl i 337flag requests display of inode information in addition to capacity information. 338This command is only supported on servers that implement the 339.Dq statvfs@openssh.com 340extension. 341.It Ic exit 342Quit 343.Nm sftp . 344.It Xo Ic get 345.Op Fl aPpr 346.Ar remote-path 347.Op Ar local-path 348.Xc 349Retrieve the 350.Ar remote-file 351and store it on the local machine. 352If the local 353path name is not specified, it is given the same name it has on the 354remote machine. 355.Ar remote-path 356may contain 357.Xr glob 3 358characters and may match multiple files. 359If it does and 360.Ar local-path 361is specified, then 362.Ar local-path 363must specify a directory. 364.Pp 365If the 366.Fl a 367flag is specified, then attempt to resume partial transfers of existing files. 368Note that resumption assumes that any partial copy of the local file matches 369the remote copy. 370If the remote file differs from the partial local copy then the resultant file 371is likely to be corrupt. 372.Pp 373If either the 374.Fl P 375or 376.Fl p 377flag is specified, then full file permissions and access times are 378copied too. 379.Pp 380If the 381.Fl r 382flag is specified then directories will be copied recursively. 383Note that 384.Nm 385does not follow symbolic links when performing recursive transfers. 386.It Ic help 387Display help text. 388.It Ic lcd Ar path 389Change local directory to 390.Ar path . 391.It Ic lls Op Ar ls-options Op Ar path 392Display local directory listing of either 393.Ar path 394or current directory if 395.Ar path 396is not specified. 397.Ar ls-options 398may contain any flags supported by the local system's 399.Xr ls 1 400command. 401.Ar path 402may contain 403.Xr glob 3 404characters and may match multiple files. 405.It Ic lmkdir Ar path 406Create local directory specified by 407.Ar path . 408.It Xo Ic ln 409.Op Fl s 410.Ar oldpath 411.Ar newpath 412.Xc 413Create a link from 414.Ar oldpath 415to 416.Ar newpath . 417If the 418.Fl s 419flag is specified the created link is a symbolic link, otherwise it is 420a hard link. 421.It Ic lpwd 422Print local working directory. 423.It Ic ls Oo Fl 1afhlnrSt Oc Oo Ar path Oc 424Display a remote directory listing of either 425.Ar path 426or the current directory if 427.Ar path 428is not specified. 429.Ar path 430may contain 431.Xr glob 3 432characters and may match multiple files. 433.Pp 434The following flags are recognized and alter the behaviour of 435.Ic ls 436accordingly: 437.Bl -tag -width Ds 438.It Fl 1 439Produce single columnar output. 440.It Fl a 441List files beginning with a dot 442.Pq Sq \&. . 443.It Fl f 444Do not sort the listing. 445The default sort order is lexicographical. 446.It Fl h 447When used with a long format option, use unit suffixes: Byte, Kilobyte, 448Megabyte, Gigabyte, Terabyte, Petabyte, and Exabyte in order to reduce 449the number of digits to four or fewer using powers of 2 for sizes (K=1024, 450M=1048576, etc.). 451.It Fl l 452Display additional details including permissions 453and ownership information. 454.It Fl n 455Produce a long listing with user and group information presented 456numerically. 457.It Fl r 458Reverse the sort order of the listing. 459.It Fl S 460Sort the listing by file size. 461.It Fl t 462Sort the listing by last modification time. 463.El 464.It Ic lumask Ar umask 465Set local umask to 466.Ar umask . 467.It Ic mkdir Ar path 468Create remote directory specified by 469.Ar path . 470.It Ic progress 471Toggle display of progress meter. 472.It Ic put Oo Fl Ppr Oc Ar local-path Oo Ar remote-path Oc 473Upload 474.Ar local-path 475and store it on the remote machine. 476If the remote path name is not specified, it is given the same name it has 477on the local machine. 478.Ar local-path 479may contain 480.Xr glob 3 481characters and may match multiple files. 482If it does and 483.Ar remote-path 484is specified, then 485.Ar remote-path 486must specify a directory. 487.Pp 488If either the 489.Fl P 490or 491.Fl p 492flag is specified, then full file permissions and access times are 493copied too. 494.Pp 495If the 496.Fl r 497flag is specified then directories will be copied recursively. 498Note that 499.Nm 500does not follow symbolic links when performing recursive transfers. 501.It Ic pwd 502Display remote working directory. 503.It Ic quit 504Quit 505.Nm sftp . 506.It Xo Ic reget 507.Op Fl Ppr 508.Ar remote-path 509.Op Ar local-path 510.Xc 511Resume download of 512.Ar remote-path . 513Equivalent to 514.Ic get 515with the 516.Fl a 517flag set. 518.It Ic rename Ar oldpath Ar newpath 519Rename remote file from 520.Ar oldpath 521to 522.Ar newpath . 523.It Ic rm Ar path 524Delete remote file specified by 525.Ar path . 526.It Ic rmdir Ar path 527Remove remote directory specified by 528.Ar path . 529.It Ic symlink Ar oldpath Ar newpath 530Create a symbolic link from 531.Ar oldpath 532to 533.Ar newpath . 534.It Ic version 535Display the 536.Nm 537protocol version. 538.It Ic \&! Ns Ar command 539Execute 540.Ar command 541in local shell. 542.It Ic \&! 543Escape to local shell. 544.It Ic \&? 545Synonym for help. 546.El 547.Sh SEE ALSO 548.Xr ftp 1 , 549.Xr ls 1 , 550.Xr scp 1 , 551.Xr ssh 1 , 552.Xr ssh-add 1 , 553.Xr ssh-keygen 1 , 554.Xr glob 3 , 555.Xr ssh_config 5 , 556.Xr sftp-server 8 , 557.Xr sshd 8 558.Rs 559.%A T. Ylonen 560.%A S. Lehtinen 561.%T "SSH File Transfer Protocol" 562.%N draft-ietf-secsh-filexfer-00.txt 563.%D January 2001 564.%O work in progress material 565.Re 566