SFTP Commands Cheatsheet
SFTP Command Reference
This cheatsheet provides essential SFTP commands for secure file transfer operations. SFTP (SSH File Transfer Protocol) is a secure way to transfer files over an SSH connection.
Connecting to an SFTP Server
Use the following command to establish an SFTP connection to a remote server. You'll typically need your username, the server's domain or IP address, and potentially an SSH private key.
$ sftp -i ~/.ssh/id_rsa me@sftp.mydomain.com
Managing Directories
Navigate and manage directories on both your local machine and the remote SFTP server.
Local Directory Commands
sftp> lpwd # Print local working directory
sftp> lcd # Change local directory
sftp> lls # List local files
sftp> lmkdir data # Create local directory
Remote Directory Commands
sftp> pwd # Print remote working directory
sftp> cd # Change remote directory
sftp> ls # List remote files
sftp> mkdir data # Create remote directory
sftp> rm data # Delete remote directory (must be empty)
File Transfer Operations
Transfer files between your local machine and the SFTP server securely.
Uploading Files
Upload single or multiple files from your local machine to the remote server.
sftp> put file.json # Upload a single file to the current remote directory
sftp> put file.json path/to/file.json # Upload a single file to a specific remote path
sftp> mput *.json # Upload multiple files matching a pattern
Downloading Files
Download single or multiple files from the remote server to your local machine.
sftp> get file.json # Download a single file to the current local directory
sftp> mget *.json # Download multiple files matching a pattern
Additional SFTP Commands
Explore other useful commands for managing your SFTP session.
sftp> help # Display available commands
sftp> quit # Exit the SFTP session
For more advanced usage and security best practices regarding SFTP, refer to the official SSH documentation and resources like MDN Web Docs on HTTP and SSH.com SFTP Guide.