SFTP(1)

πŸ“¦
version 10.2p1 Β· 3 versions
, in fedora 44

✨ sftp(1) β€” OpenSSH secure file transfer ✨

okay bestie, this is the General Commands Manual, section 1, and we're about to get into it πŸ’…

🌸 NAME 🌸

sftp β€” OpenSSH secure file transfer

πŸ¦‹ SYNOPSIS πŸ¦‹

sftp [-46AaCfNpqrv] [-B buffer_size] [-b batchfile] [-c cipher]
     [-D sftp_server_command] [-F ssh_config] [-i identity_file]
     [-J destination] [-l limit] [-o ssh_option] [-P port]
     [-R num_requests] [-S program] [-s subsystem | sftp_server]
     [-X sftp_option] destination

πŸ’… DESCRIPTION πŸ’…

So sftp is a file transfer program, like ftp(1) but make it secure β€” it does all its operations over an encrypted ssh(1) transport. It can also use many features of ssh, like public key authentication and compression. And get this: sftp is binary compatible with OpenSSH's sftp and uses the same directive and configuration options except where noted. Periodt.

The destination can be either [user@]host[:path] or a URI in the form sftp://[user@]host[:port][/path]. ✨

If the destination includes a path and it is not a directory, sftp will retrieve files automatically if a non-interactive authentication method is used; otherwise it will do so after successful interactive authentication. Like, it's giving "I got you, bestie".

If no path is specified, or if the path is a directory, sftp will log in to the specified host and enter interactive command mode, changing to the remote directory if one was specified. An optional trailing slash can be used to force the path to be interpreted as a directory. Slay.

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. No cap.

The options are as follows:

πŸ‘‘ OPTIONS πŸ‘‘

  • -4 β€” Forces sftp to use IPv4 addresses only. Like, IPv4 only, no IPv6 allowed πŸ’…
  • -6 β€” Forces sftp to use IPv6 addresses only. The IPv6 era, periodt.
  • -A β€” Allows forwarding of ssh-agent(1) to the remote system. The default is not to forward an authentication agent. So if you want that agent forwarding vibe, you gotta ask for it.
  • -a β€” Attempt to continue interrupted transfers rather than overwriting existing partial or complete copies of files. ⚠️ But heads up: if the partial contents differ from those being transferred, then the resultant file is likely to be corrupt. So, like, use with caution bestie.
  • -B buffer_size β€” Specify the size of the buffer that sftp uses when transferring files. Larger buffers require fewer round trips at the cost of higher memory consumption. The default is 32768 bytes. It's giving "bigger buffer, bigger memory energy".
  • -b batchfile β€” Batch mode reads a series of commands from an input batchfile instead of stdin. 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 sshd(8) and ssh-keygen(1) for details).

A batchfile of - may be used to indicate standard input. sftp will abort if any of the following commands fail: get, put, reget, reput, rename, ln, rm, mkdir, chdir, ls, lchdir, copy, cp, chmod, chown, chgrp, lpwd, df, symlink, and lmkdir.

Termination on error can be suppressed on a command by command basis by prefixing the command with a - character (for example, -rm /tmp/blah*). 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 -@ls /bsd. Iconic.

  • -C β€” Enables compression (via ssh's -C flag). Zip it, squeeze it, make it smaller ✨
  • -c cipher β€” Selects the cipher to use for encrypting the data transfers. This option is directly passed to ssh(1). Choose your fighter.
  • -D sftp_server_command β€” Connect directly to a local sftp server (rather than via ssh(1)). A command and arguments may be specified, for example "/path/sftp-server -el debug3". This option may be useful in debugging the client and server. Like, direct connect, no ssh middleman.
  • -F ssh_config β€” Specifies an alternative per-user configuration file for ssh(1). This option is directly passed to ssh(1). Custom config, your rules.
  • -f β€” Requests that files be flushed to disk immediately after transfer. When uploading files, this feature is only enabled if the server implements the "fsync@openssh.com" extension. Flush it, bestie πŸ’…
  • -i identity_file β€” Selects the file from which the identity (private key) for public key authentication is read. This option is directly passed to ssh(1). Your key, your identity, your vibe.
  • -J destination β€” Connect to the target host by first making an sftp connection to the jump host described by destination 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 ProxyJump configuration directive. This option is directly passed to ssh(1). Jumping through hosts like it's a Mario level.
  • -l limit β€” Limits the used bandwidth, specified in Kbit/s. Throttle it, control the flow.
  • -N β€” Disables quiet mode, e.g. to override the implicit quiet mode set by the -b flag. Not quiet, loud and proud.
  • -o ssh_option β€” Can be used to pass options to ssh in the format used in ssh_config(5). This is useful for specifying options for which there is no separate sftp command-line flag. For example, to specify an alternate port use: sftp -oPort=24. For full details of the options listed below, and their possible values, see ssh_config(5).
    • AddKeysToAgent
    • AddressFamily
    • BatchMode
    • BindAddress
    • BindInterface
    • CASignatureAlgorithms
    • CanonicalDomains
    • CanonicalizeFallbackLocal
    • CanonicalizeHostname
    • CanonicalizeMaxDots
    • CanonicalizePermittedCNAMEs
    • CertificateFile
    • ChannelTimeout
    • CheckHostIP
    • Ciphers
    • ClearAllForwardings
    • Compression
    • ConnectTimeout
    • ConnectionAttempts
    • ControlMaster
    • ControlPath
    • ControlPersist
    • DynamicForward
    • EnableEscapeCommandline
    • EnableSSHKeysign
    • EscapeChar
    • ExitOnForwardFailure
    • FingerprintHash
    • ForkAfterAuthentication
    • ForwardAgent
    • ForwardX11
    • ForwardX11Timeout
    • ForwardX11Trusted
    • GSSAPIAuthentication
    • GSSAPIDelegateCredentials
    • GatewayPorts
    • GlobalKnownHostsFile
    • HashKnownHosts
    • Host
    • HostKeyAlgorithms
    • HostKeyAlias
    • HostbasedAcceptedAlgorithms
    • HostbasedAuthentication
    • Hostname
    • IPQoS
    • IdentitiesOnly
    • IdentityAgent
    • IdentityFile
    • IgnoreUnknown
    • Include
    • KbdInteractiveAuthentication
    • KbdInteractiveDevices
    • KexAlgorithms
    • KnownHostsCommand
    • LocalCommand
    • LocalForward
    • LogLevel
    • LogVerbose
    • MACs
    • NoHostAuthenticationForLocalhost
    • NumberOfPasswordPrompts
    • ObscureKeystrokeTiming
    • PKCS11Provider
    • PasswordAuthentication
    • PermitLocalCommand
    • PermitRemoteOpen
    • Port
    • PreferredAuthentications
    • ProxyCommand
    • ProxyJump
    • ProxyUseFdpass
    • PubkeyAcceptedAlgorithms
    • PubkeyAuthentication
    • RekeyLimit
    • RemoteCommand
    • RemoteForward
    • RequestTTY
    • RequiredRSASize
    • RevokedHostKeys
    • SecurityKeyProvider
    • SendEnv
    • ServerAliveCountMax
    • ServerAliveInterval
    • SessionType
    • SetEnv
    • StdinNull
    • StreamLocalBindMask
    • StreamLocalBindUnlink
    • StrictHostKeyChecking
    • SyslogFacility
    • TCPKeepAlive
    • Tag
    • Tunnel
    • TunnelDevice
    • UpdateHostKeys
    • UseMPTCP
    • User
    • UserKnownHostsFile
    • VerifyHostKeyDNS
    • VisualHostKey
    • XAuthLocation
  • -P port β€” Specifies the port to connect to on the remote host. Port check, bestie.
  • -p β€” Preserves modification times, access times, and modes from the original files transferred. Keeping those timestamps and permissions intact, periodt.
  • -q β€” Quiet mode: disables the progress meter as well as warning and diagnostic messages from ssh(1). Shhh, no noise.
  • -R num_requests β€” 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 1024 outstanding requests providing for 32MB of outstanding data with a 32KB buffer. Balance, bestie.
  • -r β€” Recursively copy entire directories when uploading and downloading. Note that sftp does not follow symbolic links encountered in the tree traversal. Recursive realness, but no symlink following.
  • -S program β€” Name of the program to use for the encrypted connection. The program must understand ssh(1) options. Custom connection program, your choice.
  • -s subsystem | sftp_server β€” Specifies the SSH2 subsystem or the path for an sftp server on the remote host. A path is useful when the remote sshd(8) does not have an sftp subsystem configured. Pick your subsystem or server path.
  • -v β€” Raise logging level. This option is also passed to ssh. Verbose mode, spill the tea.
  • -X sftp_option β€” Specify an option that controls aspects of SFTP protocol behaviour. The valid options are:
    • nrequests=value β€” Controls how many concurrent SFTP read or write requests may be in progress at any point in time during a download or upload. This value must be between 1 and 8192. By default 1024 requests may be active concurrently.
    • buffer=value β€” Controls the maximum buffer size for a single SFTP read/write operation used during download or upload. This value must be between 1B and 255KB. You may use the K unit for the size. E.g. 32768 or 32K. By default a 32KB buffer is used.

πŸŽ€ INTERACTIVE COMMANDS πŸŽ€

okay so once you're actually in interactive mode, sftp speaks its own lil language β€” a whole command set that's basically ftp(1) coded but cuter. Commands are case insensitive, so LS and ls hit the same πŸ’…. Pathnames with spaces in them? Wrap those in quotes, no exceptions. And any special characters inside a pathname that glob(3) would recognize? Escape them with backslashes (\), bestie, or the globbing will absolutely eat your filename. 😭


bye

Quit sftp. That's it, that's the whole vibe. πŸ‘‹

cd [path]

Change the remote directory to path. If you don't pass a path, it changes back to the directory the session started in β€” like a lil "take me home" button. 🏠

chgrp [-h] grp path

Change the group of file path to grp. The path can contain glob(7) characters and might match multiple files. And heads up: grp has to be a numeric GID, not a group name.

If you pass the -h flag, then symlinks will not be followed. Lowkey important caveat: this is only supported by servers that implement the "lsetstat@openssh.com" extension.

chmod [-h] mode path

Change the permissions of file path to mode. path may contain glob(7) characters and can match multiple files too. slay.

If the -h flag is specified, then symlinks will not be followed. Note that this is only supported by servers that implement the "lsetstat@openssh.com" extension.

chown [-h] own path

Change the owner of file path to own. path may contain glob(7) characters and may match multiple files. own must be a numeric UID.

If the -h flag is specified, then symlinks will not be followed. Note that this is only supported by servers that implement the "lsetstat@openssh.com" extension.

copy oldpath newpath

Copy a remote file from oldpath to newpath. ✨

Note that this is only supported by servers that implement the "copy-data" extension.

cp oldpath newpath

Alias to the copy command. Same thing, different name, we love a rebrand. πŸ’…

df [-hi] [path]

Display usage info for the filesystem holding the current directory β€” or path, if you specified one. If you pass -h, the capacity info gets shown with "human-readable" suffixes so your brain doesn't have to count zeroes. The -i flag asks for inode information in addition to the capacity info.

This command is only supported on servers that implement the "statvfs@openssh.com" extension.

exit

Quit sftp. (Yes, same energy as bye. Two doors, one exit. πŸšͺ)

get [-afpR] remote-path [local-path]

Retrieve the remote-path and stash it on your local machine. If you don't give a local path name, it just keeps the same name it had on the remote machine. remote-path may contain glob(7) characters and may match multiple files β€” and if it does match multiple, and you did give a local-path, then that local-path has to specify a directory.

If the -a flag is specified, then it'll attempt to resume partial transfers of existing files. ⚠️ Note that resumption assumes any partial copy of the local file matches the remote copy. If the remote file contents differ from that partial local copy, then the resulting file is likely to be corrupt. Not a vibe. Be careful.

If the -f flag is specified, then fsync(2) will be called after the file transfer has completed, to flush the file to disk.

If the -p flag is specified, then full file permissions and access times are copied too. 🫢

If the -R flag is specified then directories will be copied recursively. Note that sftp does not follow symbolic links when performing recursive transfers.

help

Display help text. When in doubt, ask. πŸ™ˆ

lcd [path]

Change the local directory to path. If no path is given, it changes to the local user's home directory. (Notice the l prefix = local, bestie, that's the whole code. 🧚)

lls [ls-options [path]]

Display a local directory listing β€” either of path, or of the current directory if you didn't specify one. ls-options may contain any flags supported by the local system's ls(1) command. path may contain glob(7) characters and may match multiple files.

lmkdir path

Create the local directory specified by path.

ln [-s] oldpath newpath

Create a link from oldpath to newpath. If the -s flag is specified, the created link is a symbolic link β€” otherwise it's a hard link.

lpwd

Print the local working directory. Just so you know where you are. 🌸

ls [-1afhlnrSt] [path]

Display a remote directory listing of either path or the current directory if path isn't specified. path may contain glob(7) characters and may match multiple files.

Here are the flags it recognizes, and what each one does to the vibe of your listing:

  • -1 β€” Produce single columnar output.
  • -a β€” List files beginning with a dot (.).
  • -f β€” Do not sort the listing. The default sort order is lexicographical.
  • -h β€” 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.).
  • -l β€” Display additional details including permissions and ownership information.
  • -n β€” Produce a long listing with user and group information presented numerically.
  • -r β€” Reverse the sort order of the listing.
  • -S β€” Sort the listing by file size.
  • -t β€” Sort the listing by last modification time.

lumask umask

Set the local umask to umask.

mkdir path

Create the remote directory specified by path.

progress

Toggle display of the progress meter. On, off, on, off β€” your call. πŸ¦‹

put [-afpR] local-path [remote-path]

Upload local-path and store it on the remote machine. If you don't give a remote path name, it's given the same name it has on the local machine. local-path may contain glob(7) characters and may match multiple files β€” and if it does and remote-path is specified, then remote-path must specify a directory.

If the -a flag is specified, then attempt to resume partial transfers of existing files. ⚠️ Note that resumption assumes 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.

If the -f flag is specified, then a request will be sent to the server to call fsync(2) after the file has been transferred. Note that this is only supported by servers that implement the "fsync@openssh.com" extension.

If the -p flag is specified, then full file permissions and access times are copied too.

If the -R flag is specified then directories will be copied recursively. Note that sftp does not follow symbolic links when performing recursive transfers.

pwd

Display the remote working directory. πŸ‘‘

quit

Quit sftp. Third exit door, still one exit. 😌

reget [-fpR] remote-path [local-path]

Resume download of remote-path. Equivalent to get with the -a flag set.

reput [-fpR] local-path [remote-path]

Resume upload of local-path. Equivalent to put with the -a flag set.

rename oldpath newpath

Rename a remote file from oldpath to newpath.

rm path

Delete the remote file specified by path. πŸ—‘οΈ

rmdir path

Remove the remote directory specified by path.

Create a symbolic link from oldpath to newpath.

version

Display the sftp protocol version. Nerd info, but make it cute. ⭐

!command

Execute command in the local shell. Escape hatch unlocked.

!

Escape to the local shell. Just the bang, nothing else. πŸ’₯

?

Synonym for help. Same energy, one character. πŸ™‹


🌈 SEE ALSO 🌈

And for the academic girlies keeping receipts:

T. Ylonen and S. Lehtinen, SSH File Transfer Protocol, draft-ietf-secsh-filexfer-00.txt, January 2001, work in progress material.


okay bestie that's the whole page πŸ’– this one ships with Debian, dated December 6, 2024, and it's the SFTP(1) manual page β€” go forth and transfer your files with main character energy. 🫢✨

πŸ“¦ where this page comes from
  • fedora 44: gsi-openssh-clients 10.2p1-1.fc44 Β· BSD-3-Clause AND BSD-2-Clause AND ISC AND SSH-OpenSSH AND ssh-keyscan AND sprintf AND LicenseRef-Fedora-Public-Domain AND X11-distribute-modifications-variant
  • fedora 44: gsi-openssh-clients 10.2p1-4.fc44 Β· BSD-3-Clause AND BSD-2-Clause AND ISC AND SSH-OpenSSH AND ssh-keyscan AND snprintf AND LicenseRef-Fedora-Public-Domain AND X11-distribute-modifications-variant
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms