SFTP commands: Details and guide

Cerberus by Redwood provides SFTP transfer operations via a GUI or API. However, more advanced SFTP users may seek to initiate transfers from their command lines. To support these users, we’ve provided a detailed look at the various SFTP command line operations. While these operations are common across Windows, Linux and Max due to the protocol’s flexibility, specific clients and configurations may require unique commands or arguments.

Core SFTP command line operations

Session commands

Operation Command
Open an SFTP connection sftp (followed by user@host/remote-dir)
Close an SFTP connection exit (quit or bye will frequently work as well)
Show your SFTP version version
Access available SFTP commands help or ?
Pause your SFTP session (to execute other commands) !
Return to your session exit

 

File commands

These commands generally take the following structure:

sftp> [command] [argument] [file-name] [target-path]

Arguments are not required, and if you leave the path blank, your commands will be executed on whatever current directory you are accessing. You can also add wildcards for file names and directories by using the asterisk (*).

Operation Command Example
List all files in the server’s current directory ls (or dir) sftp> ls /example-directory
Sort returned files by size -s
Sort returned files by modification time -t
Sort returned files in reverse -r
Download a file from the server to your machine get sftp> get example-file /target-local-directory
Download multiple files mget sftp> mget *.png
Upload a file from your machine to the server put sftp> put example.docx /directory-path/
Upload multiple files mput sftp> mget /local-directory/
Delete a file on the server rm sftp> rm file-path
Rename a file on the server rename sftp> rename old-name new-name

 

Directory Commands

 

Command Description Example
Change your server directory cd sftp> cd remote-server-directory
Change your local host directory lcd sftp> lcd local-host-directory
Show the server directory path pwd sftp> pwd
Show your local host directory path lpwd sftp> lpwd
Create a new server directory mkdir sftp> mkdir new-remote-server-path
Create a new local host directory lmkdir sftp> lmkdir new-local-path
Delete a server directory rmdir sftp> rmdir remote-server-path

Cerberus FTP Server also includes remote API-based management of the SFTP server, which adds an additional layer of sophistication to your command interactions. This link will take you to a reference guide for our SFTP Server API.