man-pages/man1/sftp.1.html
2021-03-31 01:06:50 +01:00

1436 lines
19 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of SFTP</TITLE>
</HEAD><BODY>
<H1>SFTP</H1>
Section: User Commands (1)<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<BR>BSD mandoc<BR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
<B>sftp</B>
- OpenSSH secure file transfer
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<B>sftp</B>
[-<B>46aCfpqrv</B>
]
[-<B>B </B><I>buffer_size</I>
]
[-<B>b </B><I>batchfile</I>
]
[-<B>c </B><I>cipher</I>
]
[-<B>D </B><I>sftp_server_path</I>
]
[-<B>F </B><I>ssh_config</I>
]
[-<B>i </B><I>identity_file</I>
]
[-<B>J </B><I>destination</I>
]
[-<B>l </B><I>limit</I>
]
[-<B>o </B><I>ssh_option</I>
]
[-<B>P </B><I>port</I>
]
[-<B>R </B><I>num_requests</I>
]
[-<B>S </B><I>program</I>
]
[-<B>s </B><I>subsystem | sftp_server</I>
]
<I>destination</I>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
<B>sftp</B>
is a file transfer program, similar to
<A HREF="/cgi-bin/man/man2html?1+ftp">ftp</A>(1),
which performs all operations over an encrypted
<A HREF="/cgi-bin/man/man2html?1+ssh">ssh</A>(1)
transport.
It may also use many features of ssh, such as public key authentication and
compression.
<P>
The
<I>destination</I>
may be specified either as
[user @ host [: path]
]
or as a URI in the form
<B>sftp:// </B>[user @ host [: port [/ path]
]
]
<P>
If the
<I>destination</I>
includes a
<I>path</I>
and it is not a directory,
<B>sftp</B>
will retrieve files automatically if a non-interactive
authentication method is used; otherwise it will do so after
successful interactive authentication.
<P>
If no
<I>path</I>
is specified, or if the
<I>path</I>
is a directory,
<B>sftp</B>
will log in to the specified
<I>host</I>
and enter interactive command mode, changing to the remote directory
if one was specified.
An optional trailing slash can be used to force the
<I>path</I>
to be interpreted as a directory.
<P>
Since the destination formats use colon characters to delimit host
names from path names or port numbers, IPv6 addresses must be
enclosed in square brackets to avoid ambiguity.
<P>
The options are as follows:
<DL COMPACT>
<P>
<DT id="1"><B>-4</B>
<DD>
Forces
<B>sftp</B>
to use IPv4 addresses only.
<DT id="2"><B>-6</B>
<DD>
Forces
<B>sftp</B>
to use IPv6 addresses only.
<DT id="3"><B>-a</B>
<DD>
Attempt to continue interrupted transfers rather than overwriting
existing partial or complete copies of files.
If the partial contents differ from those being transferred,
then the resultant file is likely to be corrupt.
<DT id="4"><B>-B </B><I>buffer_size</I>
<DD>
Specify the size of the buffer that
<B>sftp</B>
uses when transferring files.
Larger buffers require fewer round trips at the cost of higher
memory consumption.
The default is 32768 bytes.
<DT id="5"><B>-b </B><I>batchfile</I>
<DD>
Batch mode reads a series of commands from an input
<I>batchfile</I>
instead of
<I>stdin</I>
Since it lacks user interaction it should be used in conjunction with
non-interactive authentication to obviate the need to enter a password
at connection time (see
<A HREF="/cgi-bin/man/man2html?8+sshd">sshd</A>(8)
and
ssh-keygen1
for details).
<P>
A
<I>batchfile</I>
of
`-'
may be used to indicate standard input.
<B>sftp</B>
will abort if any of the following
commands fail:
<B>get , put , reget , reput , rename , ln</B>
<B>rm , mkdir , chdir , ls</B>
<B>lchdir , chmod , chown</B>
<B>chgrp , lpwd , df , symlink</B>
and
<B>lmkdir</B>
<P>
Termination on error can be suppressed on a command by command basis by
prefixing the command with a
`-'
character (for example,
<B>-rm /tmp/blah* )</B>
Echo of the command may be suppressed by prefixing the command with a
`@'
character.
These two prefixes may be combined in any order, for example
<B>-@ls /bsd</B>
<DT id="6"><B>-C</B>
<DD>
Enables compression (via ssh's
-<B>C</B>
flag).
<DT id="7"><B>-c </B><I>cipher</I>
<DD>
Selects the cipher to use for encrypting the data transfers.
This option is directly passed to
<A HREF="/cgi-bin/man/man2html?1+ssh">ssh</A>(1).
<DT id="8"><B>-D </B><I>sftp_server_path</I>
<DD>
Connect directly to a local sftp server
(rather than via
<A HREF="/cgi-bin/man/man2html?1+ssh">ssh</A>(1)).
This option may be useful in debugging the client and server.
<DT id="9"><B>-F </B><I>ssh_config</I>
<DD>
Specifies an alternative
per-user configuration file for
<A HREF="/cgi-bin/man/man2html?1+ssh">ssh</A>(1).
This option is directly passed to
<A HREF="/cgi-bin/man/man2html?1+ssh">ssh</A>(1).
<DT id="10"><B>-f</B>
<DD>
Requests that files be flushed to disk immediately after transfer.
When uploading files, this feature is only enabled if the server
implements the &quot;<A HREF="mailto:fsync@openssh.com">fsync@openssh.com</A>&quot; extension.
<DT id="11"><B>-i </B><I>identity_file</I>
<DD>
Selects the file from which the identity (private key) for public key
authentication is read.
This option is directly passed to
<A HREF="/cgi-bin/man/man2html?1+ssh">ssh</A>(1).
<DT id="12"><B>-J </B><I>destination</I>
<DD>
Connect to the target host by first making an
<B>sftp</B>
connection to the jump host described by
<I>destination</I>
and then establishing a TCP forwarding to the ultimate destination from
there.
Multiple jump hops may be specified separated by comma characters.
This is a shortcut to specify a
<B>ProxyJump</B>
configuration directive.
This option is directly passed to
<A HREF="/cgi-bin/man/man2html?1+ssh">ssh</A>(1).
<DT id="13"><B>-l </B><I>limit</I>
<DD>
Limits the used bandwidth, specified in Kbit/s.
<DT id="14"><B>-o </B><I>ssh_option</I>
<DD>
Can be used to pass options to
<B>ssh</B>
in the format used in
ssh_config5.
This is useful for specifying options
for which there is no separate
<B>sftp</B>
command-line flag.
For example, to specify an alternate port use:
<B>sftp -oPort=24</B>
For full details of the options listed below, and their possible values, see
ssh_config5.
<P>
<DL COMPACT>
<P>
<DT id="15"><B>AddressFamily</B>
<DD>
<DT id="16"><B>BatchMode</B>
<DD>
<DT id="17"><B>BindAddress</B>
<DD>
<DT id="18"><B>BindInterface</B>
<DD>
<DT id="19"><B>CanonicalDomains</B>
<DD>
<DT id="20"><B>CanonicalizeFallbackLocal</B>
<DD>
<DT id="21"><B>CanonicalizeHostname</B>
<DD>
<DT id="22"><B>CanonicalizeMaxDots</B>
<DD>
<DT id="23"><B>CanonicalizePermittedCNAMEs </B><DT><B>CASignatureAlgorithms</B>
<DD>
<DD>
<DT id="24"><B>CertificateFile</B>
<DD>
<DT id="25"><B>ChallengeResponseAuthentication</B>
<DD>
<DT id="26"><B>CheckHostIP</B>
<DD>
<DT id="27"><B>Ciphers</B>
<DD>
<DT id="28"><B>Compression</B>
<DD>
<DT id="29"><B>ConnectionAttempts</B>
<DD>
<DT id="30"><B>ConnectTimeout</B>
<DD>
<DT id="31"><B>ControlMaster</B>
<DD>
<DT id="32"><B>ControlPath</B>
<DD>
<DT id="33"><B>ControlPersist</B>
<DD>
<DT id="34"><B>GlobalKnownHostsFile</B>
<DD>
<DT id="35"><B>GSSAPIAuthentication</B>
<DD>
<DT id="36"><B>GSSAPIDelegateCredentials</B>
<DD>
<DT id="37"><B>HashKnownHosts</B>
<DD>
<DT id="38"><B>Host</B>
<DD>
<DT id="39"><B>HostbasedAuthentication</B>
<DD>
<DT id="40"><B>HostbasedKeyTypes</B>
<DD>
<DT id="41"><B>HostKeyAlgorithms</B>
<DD>
<DT id="42"><B>HostKeyAlias</B>
<DD>
<DT id="43"><B>Hostname</B>
<DD>
<DT id="44"><B>IdentitiesOnly</B>
<DD>
<DT id="45"><B>IdentityAgent</B>
<DD>
<DT id="46"><B>IdentityFile</B>
<DD>
<DT id="47"><B>IPQoS</B>
<DD>
<DT id="48"><B>KbdInteractiveAuthentication</B>
<DD>
<DT id="49"><B>KbdInteractiveDevices</B>
<DD>
<DT id="50"><B>KexAlgorithms</B>
<DD>
<DT id="51"><B>LogLevel</B>
<DD>
<DT id="52"><B>MACs </B><DT><B>NoHostAuthenticationForLocalhost</B>
<DD>
<DD>
<DT id="53"><B>NumberOfPasswordPrompts</B>
<DD>
<DT id="54"><B>PasswordAuthentication</B>
<DD>
<DT id="55"><B>PKCS11Provider</B>
<DD>
<DT id="56"><B>Port</B>
<DD>
<DT id="57"><B>PreferredAuthentications</B>
<DD>
<DT id="58"><B>ProxyCommand</B>
<DD>
<DT id="59"><B>ProxyJump</B>
<DD>
<DT id="60"><B>PubkeyAcceptedKeyTypes</B>
<DD>
<DT id="61"><B>PubkeyAuthentication</B>
<DD>
<DT id="62"><B>RekeyLimit</B>
<DD>
<DT id="63"><B>SendEnv</B>
<DD>
<DT id="64"><B>ServerAliveInterval</B>
<DD>
<DT id="65"><B>ServerAliveCountMax</B>
<DD>
<DT id="66"><B>SetEnv</B>
<DD>
<DT id="67"><B>StrictHostKeyChecking</B>
<DD>
<DT id="68"><B>TCPKeepAlive</B>
<DD>
<DT id="69"><B>UpdateHostKeys</B>
<DD>
<DT id="70"><B>User</B>
<DD>
<DT id="71"><B>UserKnownHostsFile</B>
<DD>
<DT id="72"><B>VerifyHostKeyDNS</B>
<DD>
</DL>
<P>
<DT id="73"><B>-P </B><I>port</I>
<DD>
Specifies the port to connect to on the remote host.
<DT id="74"><B>-p</B>
<DD>
Preserves modification times, access times, and modes from the
original files transferred.
<DT id="75"><B>-q</B>
<DD>
Quiet mode: disables the progress meter as well as warning and
diagnostic messages from
<A HREF="/cgi-bin/man/man2html?1+ssh">ssh</A>(1).
<DT id="76"><B>-R </B><I>num_requests</I>
<DD>
Specify how many requests may be outstanding at any one time.
Increasing this may slightly improve file transfer speed
but will increase memory usage.
The default is 64 outstanding requests.
<DT id="77"><B>-r</B>
<DD>
Recursively copy entire directories when uploading and downloading.
Note that
<B>sftp</B>
does not follow symbolic links encountered in the tree traversal.
<DT id="78"><B>-S </B><I>program</I>
<DD>
Name of the
<I>program</I>
to use for the encrypted connection.
The program must understand
<A HREF="/cgi-bin/man/man2html?1+ssh">ssh</A>(1)
options.
<DT id="79"><B>-s </B><I>subsystem | sftp_server</I>
<DD>
Specifies the SSH2 subsystem or the path for an sftp server
on the remote host.
A path is useful when the remote
<A HREF="/cgi-bin/man/man2html?8+sshd">sshd</A>(8)
does not have an sftp subsystem configured.
<DT id="80"><B>-v</B>
<DD>
Raise logging level.
This option is also passed to ssh.
</DL>
<P>
<A NAME="lbAE">&nbsp;</A>
<H2>INTERACTIVE COMMANDS</H2>
Once in interactive mode,
<B>sftp</B>
understands a set of commands similar to those of
<A HREF="/cgi-bin/man/man2html?1+ftp">ftp</A>(1).
Commands are case insensitive.
Pathnames that contain spaces must be enclosed in quotes.
Any special characters contained within pathnames that are recognized by
<A HREF="/cgi-bin/man/man2html?3+glob">glob</A>(3)
must be escaped with backslashes
(`\'
)
<DL COMPACT>
<P>
<DT id="81"><B>bye</B>
<DD>
Quit
<B>sftp</B>
<DT id="82"><B>cd </B>[<I>path</I>
]
<DD>
Change remote directory to
<I>path</I>
If
<I>path</I>
is not specified, then change directory to the one the session started in.
<DT id="83"><B>
chgrp</B>
[-<B>h</B>
]
<I>grp</I>
<I>path</I>
<DD>
<DD>Change group of file
<I>path</I>
to
<I>grp</I>
If the
-<B>h</B>
flag is specified, then symlinks will not be followed.
<I>path</I>
may contain
<A HREF="/cgi-bin/man/man2html?7+glob">glob</A>(7)
characters and may match multiple files.
<I>grp</I>
must be a numeric GID.
<DT id="84"><B>
chmod</B>
[-<B>h</B>
]
<I>mode</I>
<I>path</I>
<DD>
<DD>Change permissions of file
<I>path</I>
to
<I>mode</I>
If the
-<B>h</B>
flag is specified, then symlinks will not be followed.
<I>path</I>
may contain
<A HREF="/cgi-bin/man/man2html?7+glob">glob</A>(7)
characters and may match multiple files.
<DT id="85"><B>
chown</B>
[-<B>h</B>
]
<I>own</I>
<I>path</I>
<DD>
<DD>Change owner of file
<I>path</I>
to
<I>own</I>
If the
-<B>h</B>
flag is specified, then symlinks will not be followed.
<I>path</I>
may contain
<A HREF="/cgi-bin/man/man2html?7+glob">glob</A>(7)
characters and may match multiple files.
<I>own</I>
must be a numeric UID.
<DT id="86"><B>
df</B>
[-<B>hi</B>
]
[<I>path</I>
]
<DD>
<DD>Display usage information for the filesystem holding the current directory
(or
<I>path</I>
if specified).
If the
-<B>h</B>
flag is specified, the capacity information will be displayed using
&quot;human-readable&quot; suffixes.
The
-<B>i</B>
flag requests display of inode information in addition to capacity information.
This command is only supported on servers that implement the
``<A HREF="mailto:statvfs@openssh.com">statvfs@openssh.com</A>''
extension.
<DT id="87"><B>exit</B>
<DD>
Quit
<B>sftp</B>
<DT id="88"><B>
get</B>
[-<B>afpR</B>
]
<I>remote-path</I>
[<I>local-path</I>
]
<DD>
<DD>Retrieve the
<I>remote-path</I>
and store it on the local machine.
If the local
path name is not specified, it is given the same name it has on the
remote machine.
<I>remote-path</I>
may contain
<A HREF="/cgi-bin/man/man2html?7+glob">glob</A>(7)
characters and may match multiple files.
If it does and
<I>local-path</I>
is specified, then
<I>local-path</I>
must specify a directory.
<P>
If the
-<B>a</B>
flag is specified, then attempt to resume partial transfers of existing files.
Note that resumption assumes that any partial copy of the local file matches
the remote copy.
If the remote file contents differ from the partial local copy then the
resultant file is likely to be corrupt.
<P>
If the
-<B>f</B>
flag is specified, then
<A HREF="/cgi-bin/man/man2html?2+fsync">fsync</A>(2)
will be called after the file transfer has completed to flush the file
to disk.
<P>
If the
-<B>p</B>
flag is specified, then full file permissions and access times are
copied too.
<P>
If the
-<B>R</B>
flag is specified then directories will be copied recursively.
Note that
<B>sftp</B>
does not follow symbolic links when performing recursive transfers.
<DT id="89"><B>help</B>
<DD>
Display help text.
<DT id="90"><B>lcd </B>[<I>path</I>
]
<DD>
Change local directory to
<I>path</I>
If
<I>path</I>
is not specified, then change directory to the local user's home directory.
<DT id="91"><B>lls </B>[<I>ls-options </I>[<I>path</I>
]
]
<DD>
Display local directory listing of either
<I>path</I>
or current directory if
<I>path</I>
is not specified.
<I>ls-options</I>
may contain any flags supported by the local system's
<A HREF="/cgi-bin/man/man2html?1+ls">ls</A>(1)
command.
<I>path</I>
may contain
<A HREF="/cgi-bin/man/man2html?7+glob">glob</A>(7)
characters and may match multiple files.
<DT id="92"><B>lmkdir </B><I>path</I>
<DD>
Create local directory specified by
<I>path</I>
<DT id="93"><B>
ln</B>
[-<B>s</B>
]
<I>oldpath</I>
<I>newpath</I>
<DD>
<DD>Create a link from
<I>oldpath</I>
to
<I>newpath</I>
If the
-<B>s</B>
flag is specified the created link is a symbolic link, otherwise it is
a hard link.
<DT id="94"><B>lpwd</B>
<DD>
Print local working directory.
<DT id="95"><B>
ls</B>
[-<B>1afhlnrSt </B>[<I>path</I>
]
]
<DD>
<DD>Display a remote directory listing of either
<I>path</I>
or the current directory if
<I>path</I>
is not specified.
<I>path</I>
may contain
<A HREF="/cgi-bin/man/man2html?7+glob">glob</A>(7)
characters and may match multiple files.
<P>
The following flags are recognized and alter the behaviour of
<B>ls</B>
accordingly:
<DL COMPACT>
<P>
<DT id="96"><B>-1</B>
<DD>
Produce single columnar output.
<DT id="97"><B>-a</B>
<DD>
List files beginning with a dot
(`.'
)
<DT id="98"><B>-f</B>
<DD>
Do not sort the listing.
The default sort order is lexicographical.
<DT id="99"><B>-h</B>
<DD>
When used with a long format option, use unit suffixes: Byte, Kilobyte,
Megabyte, Gigabyte, Terabyte, Petabyte, and Exabyte in order to reduce
the number of digits to four or fewer using powers of 2 for sizes (K=1024,
M=1048576, etc.).
<DT id="100"><B>-l</B>
<DD>
Display additional details including permissions
and ownership information.
<DT id="101"><B>-n</B>
<DD>
Produce a long listing with user and group information presented
numerically.
<DT id="102"><B>-r</B>
<DD>
Reverse the sort order of the listing.
<DT id="103"><B>-S</B>
<DD>
Sort the listing by file size.
<DT id="104"><B>-t</B>
<DD>
Sort the listing by last modification time.
</DL>
<P>
<DT id="105"><B>lumask </B><I>umask</I>
<DD>
Set local umask to
<I>umask</I>
<DT id="106"><B>mkdir </B><I>path</I>
<DD>
Create remote directory specified by
<I>path</I>
<DT id="107"><B>progress</B>
<DD>
Toggle display of progress meter.
<DT id="108"><B>
put</B>
[-<B>afpR</B>
]
<I>local-path</I>
[<I>remote-path</I>
]
<DD>
<DD>Upload
<I>local-path</I>
and store it on the remote machine.
If the remote path name is not specified, it is given the same name it has
on the local machine.
<I>local-path</I>
may contain
<A HREF="/cgi-bin/man/man2html?7+glob">glob</A>(7)
characters and may match multiple files.
If it does and
<I>remote-path</I>
is specified, then
<I>remote-path</I>
must specify a directory.
<P>
If the
-<B>a</B>
flag is specified, then attempt to resume partial
transfers of existing files.
Note that resumption assumes that any partial copy of the remote file
matches the local copy.
If the local file contents differ from the remote local copy then
the resultant file is likely to be corrupt.
<P>
If the
-<B>f</B>
flag is specified, then a request will be sent to the server to call
<A HREF="/cgi-bin/man/man2html?2+fsync">fsync</A>(2)
after the file has been transferred.
Note that this is only supported by servers that implement
the &quot;<A HREF="mailto:fsync@openssh.com">fsync@openssh.com</A>&quot; extension.
<P>
If the
-<B>p</B>
flag is specified, then full file permissions and access times are
copied too.
<P>
If the
-<B>R</B>
flag is specified then directories will be copied recursively.
Note that
<B>sftp</B>
does not follow symbolic links when performing recursive transfers.
<DT id="109"><B>pwd</B>
<DD>
Display remote working directory.
<DT id="110"><B>quit</B>
<DD>
Quit
<B>sftp</B>
<DT id="111"><B>
reget</B>
[-<B>fpR</B>
]
<I>remote-path</I>
[<I>local-path</I>
]
<DD>
<DD>Resume download of
<I>remote-path</I>
Equivalent to
<B>get</B>
with the
-<B>a</B>
flag set.
<DT id="112"><B>
reput</B>
[-<B>fpR</B>
]
<I>local-path</I>
[<I>remote-path</I>
]
<DD>
<DD>Resume upload of
<I>local-path</I>
Equivalent to
<B>put</B>
with the
-<B>a</B>
flag set.
<DT id="113"><B>rename </B><I>oldpath newpath</I>
<DD>
Rename remote file from
<I>oldpath</I>
to
<I>newpath</I>
<DT id="114"><B>rm </B><I>path</I>
<DD>
Delete remote file specified by
<I>path</I>
<DT id="115"><B>rmdir </B><I>path</I>
<DD>
Remove remote directory specified by
<I>path</I>
<DT id="116"><B>symlink </B><I>oldpath newpath</I>
<DD>
Create a symbolic link from
<I>oldpath</I>
to
<I>newpath</I>
<DT id="117"><B>version</B>
<DD>
Display the
<B>sftp</B>
protocol version.
<DT id="118"><B>! </B><I>command</I>
<DD>
Execute
<I>command</I>
in local shell.
<DT id="119"><B>!</B>
<DD>
Escape to local shell.
<DT id="120"><B>?</B>
<DD>
Synonym for help.
</DL>
<P>
<A NAME="lbAF">&nbsp;</A>
<H2>SEE ALSO</H2>
<A HREF="/cgi-bin/man/man2html?1+ftp">ftp</A>(1),
<A HREF="/cgi-bin/man/man2html?1+ls">ls</A>(1),
<A HREF="/cgi-bin/man/man2html?1+scp">scp</A>(1),
<A HREF="/cgi-bin/man/man2html?1+ssh">ssh</A>(1),
ssh-add1,
ssh-keygen1,
ssh_config5,
<A HREF="/cgi-bin/man/man2html?7+glob">glob</A>(7),
sftp-server8,
<A HREF="/cgi-bin/man/man2html?8+sshd">sshd</A>(8)
<DL COMPACT><DT id="121"><DD>
T. Ylonen
S. Lehtinen
<I>&quot;SSH File Transfer Protocol&quot;</I>
draft-ietf-secsh-filexfer-00.txt
January 2001
work in progress material
</DL>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="122"><A HREF="#lbAB">NAME</A><DD>
<DT id="123"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="124"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="125"><A HREF="#lbAE">INTERACTIVE COMMANDS</A><DD>
<DT id="126"><A HREF="#lbAF">SEE ALSO</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:27 GMT, March 31, 2021
</BODY>
</HTML>