SFTP commands and options

This section is comprised of available SFTP command options that can be incorporated, as well as an example of SFTP use.

Additional details on SFTP can be found here: https://man.openbsd.org/sftp

SFTP connection command format

Values displayed in “< >” represent variables. The “< >” characters are not used in the input.

sftp [-Cv] [-B <buffer_size>] [-b <batchfile>] [-F <ssh_config>][-o <ssh_option] [-P <sftp_server_path>] [-R <#_of_requests>][-S <program>] [-s <subsystem | sftp_server>] hostsftp [[user@]host[:file [file]]]sftp [[user@]host[:dir[/]]]sftp -b <batchfile> [user@]host
Example SFTP connection

This example uses the OpenSSH SFTP client from a command line. It uses an example domain name prefix of nsmediadocs and the sftp.upload.akamai.com upload domain.

#> sftp -i <private key> sshacs@nsmediadocs.sftp.upload.akamai.com
Connected to sshacs@nsmediadocs.sftp.upload.akamai.com.

Connection command options

This table covers the command options available for use during the connection process.

Note: This list of commands and options are specific to the OpenSSH SFTP client and can vary depending on the client used. For example, the PuTTY PSFTP client adds options (e.g., recursive directory traversal) not available to the OpenSSH client.
Command or Option Description
-1 Use SSH protocol 1
Note: NetStorage does not support SSH protocol 1 — This command is not supported.
-B <buffer_size> Include this option and set the “<buffer_size>” variable to a desired new file transfer buffer size, in bytes (“32768” bytes is the default).
-b <batch file> Include this command and set the “<batch file>” variable to the command file to use in batch mode
-C Use compression
-F <ssh_config> Designate a substitute per-user SSH configuration file, defining it as the “<ssh_config>” variable
-o <ssh_option> Send the specified “<ssh_option>” to SSH in the ssh_config format. Available options include the following (Detailed information on each of these options can be found at http://www.openbsd.org/cgi-bin/man.cgi?query=ssh_config):
  • AddressFamily
  • BatchMode
  • BindAddress
  • ChallengeResponseAuthentication
  • CheckHostIP
  • Cipher
  • Ciphers
  • Compression
  • CompressionLevel
  • ConnectionAttempts
  • ConnectTimeout
  • ControlMaster
  • ControlPath
  • GlobalKnownHostsFile
  • GSSAPIAuthentication
  • GSSAPIDelegateCredentials
  • HashKnownHosts
  • Host
  • HostbasedAuthentication
  • HostKeyAlgorithm
  • HostKeyAlias
  • HostName
  • IdentityFile
-o <ssh_option> (cont.)
  • IdentitiesOnly
  • KbdInteractiveDevices
  • LogLevel
  • MACs
  • NoHostAuthenticationForLocalHost
  • NumberOfPasswordPrompts
  • PasswordAuthentication
  • Port
  • PreferredAuthentications
  • Protocol
  • ProxyCommand
  • PubKeyAuthentication
  • RekeyLimit
  • RhostsRSAAuthentication
  • RSAAuthentication
  • SendEnv
  • ServerAliveInterval
  • ServerAliveCountMax
  • SmartcardDevice
  • StrictHostKeyChecking
  • TCPKeepAlive
  • UsePrivilegedPort
  • User
  • UserKnownHostsFile
  • VerifyHostKeyDNS
-P <sftp_server_path> Connect to a local SFTP server without using SSH
-R <#_of _requests> Specify the number of allowed concurrent requests
-S <program> Specify the program to use for connecting to the destination
-s <subsystem | sftp_server> Designate the subsystem for the SSH2 protocol or an SFTP server’s path
-v Increase the amount of logging

Interactive SFTP command options

This table covers the interactive command options available for use during an active SFTP connection.

Note: This list of commands and options are specific to the OpenSSH SFTP client and can vary depending on the client used. For example, the PuTTY PSFTP client adds options (e.g., recursive directory traversal) not available to the OpenSSH client.
Command Description
cd <path> Change to a new remote directory (i.e., by setting that directory as the <path> variable)
chgrp <grp> path Change the file group by setting the <group> variable to a new one.
exit End the SFTP session
get [-P] <remote-path> Copy content from the remote machine to the local machine (i.e., set the complete path to, and file name of the target file as the <remote-path> variable). Including [-P] will include full file permissions and access times
help Display help information
lcd <path> Change to a new directory on the local machine (i.e., by defining the desired directory path as the <path> variable)
lls [ls-<options> [<path>]] Display the contents of a named directory on the local machine (i.e., the directory path set as the <path> variable). Additionally, the ls-<options> option can be included, in which case the <options> variable can be populated with any of the options supported for use with the ls-<option> command.
Note: if the ls-<option> option is not required, the syntax of this command would be as follows: lls <path> (i.e, no brackets -- “[ ]” -- are required).
lmkdir <path> Create a new directory on the local machine (i.e., using the path defined as the <path> variable)
ln <oldpath> <newpath> Generate a symbolic link with the original path defined as the <oldpath> variable, and the new path defined as the <newpath> variable.
lpwd Display the local machine’s working directory
ls [-<option>] [path] Display the contents of a named directory by specifying the complete path to it as the <path> variable (either on the local machine or remote). Additionally, the Additionally, the [-<option>] option can be included, in which case the <option> variable can be populated with any of the followoing options:
  • -1 - List the output in a single column
  • -a - Include files that start with a dot (“.”)
  • -f - Keep the list unsorted
  • -l - Include additional file information such as permissions and ownership
  • -n - Display a numerically-presented long listing that includes user and group information
  • -r - Sort in reverse order
  • -S - Use file size to sort the list
  • -t - Use last modification time to sort the list
Note: if the -<option> option is not required, the syntax of this command would be as follows: ls <path> (i.e, no brackets -- “[ ]” -- are required).
lumask umask Set the umask on the local machine
mkdir <path> 1 Create a new directory on the remote machine (i.e., using the path defined as the <path> variable)
progress Enable/disable the progress meter (i.e., passing this command will change the current state to the reverse).
put [-P] <local path> [<remote path>] Copy content from the path set as <local path> from the local machine to the path set as <remote path> on the remote machine. Include the [-P] option to include full file permissions and access times.
pwd Display the path of the current remote directory
quit End the SFTP session
rename <old path> <new path> Change a file’s name by specifying the existing path and filename as the <old path> variable, and the new path and filename as the <new path> variable
rm <path> Include this command and set the <path> variable to the complete path and filename of a file to be removed.
rmdir <path> Delete the directory named in the <path> variable
symlink <old path> <new path> Generate a symbolic link between the path established as the <old path> variable and the one established as the <new path> variable
version Show the version of the SFTP protocol
! <command> Use the local shell to perform a specified <command>
! Temporarily return to the local shell
? Display help information
bye End the SFTP session
1 See the section, “SFTP restrictions with ObjectStore” regarding limitations that may apply to the use of this command/option