GICT knowledge base
10 Useful SFTP Commands for Linux File Transfers
Published
OpenSSH sftp transfers files through SSH. Start with the host, port, account and authorized authentication method supplied by your administrator. Verify the server’s SSH host-key fingerprint independently before trusting a new connection. Encryption does not replace endpoint security or account permissions.
Connect to the right endpoint
sftp -P 2222 -i ~/.ssh/transfer_ed25519 user@server.example
This is an illustrative template. Replace the host, port, identity and account with authorized values. SFTP access is not implied by an FTP account. Passwords and keys depend on server policy; neither is universally required.
Ten useful interactive commands
Type these at the SFTP prompt without copying the prompt itself. Paths are examples; create and manipulate only files you own and intend to change.
| Command | Purpose |
|---|---|
| pwd | Show the remote working directory. |
| lpwd | Show the local working directory. |
| ls | List remote entries. Use lls for local entries. |
| cd /upload | Change the remote directory. Use lcd for a local directory. |
| get report.txt downloaded.txt | Download a remote file to an explicit local name. |
| put local.txt uploaded.txt | Upload a local file to an explicit remote name. |
| mkdir drafts | Create a remote directory where permitted. |
| rename uploaded.txt final.txt | Rename a remote entry; confirm destination behavior before touching valuable files. |
| rm final.txt | Delete that remote file, not a local copy. Use rmdir only for an intended empty remote directory. |
| bye | End the session. help or ? lists supported commands before you exit. |
Preservation, progress and large transfers
OpenSSH get -p or get -P preserves applicable source times and permission bits; the corresponding put flags have preservation semantics too. They do not mean “show progress.” The interactive progress command toggles the progress meter. Check your installed manual for recursive and resume flags: resuming against the wrong existing content can corrupt the result.
Quote paths with spaces and review wildcard matches before bulk transfers. Check free space and overwrites at both ends. A transfer failure may leave a partial file; do not publish it as complete. Compare important results and keep private keys or backup exports out of public directories.
Automation and troubleshooting
Batch mode can stop on failed operations and should use explicitly verified host keys and noninteractive authentication. Do not put a password in the batch file or suppress all errors. A jailed account may see a different root and no shell; remote /upload can be correct even though the administrator sees a longer host path. Permission failures do not justify disabling the jail or granting 777.
Reference: OpenSSH SFTP command and option manual.
Reviewed October 15, 2026. Upload, download, navigation, rename and removal were checked with synthetic files on a disposable loopback SSH service, not a customer account.
Related guides
How to Restrict an SSH Key to One Command
Restrict an SSH key to one command with authorized_keys options. Protect the command and check that unwanted shell and forwarding access are denied.
Linux and CommandsSelf-Hosted Video Processing With FFmpeg: A Practical Guide
Learn how to self-host video processing on a VPS using FFmpeg, with practical commands for conversion, compression, thumbnails, and automated workflows.
Linux and CommandsHow to use nohup: Commands in Linux That Survive Terminal Closes
Keep commands running after you close the terminal. nohup examples with wget, Python, rsync, and Docker on any VPS.
Linux and CommandsHow to Fix “Too Many Open Files” Error on Linux Servers
Learn how to fix the "Too Many Open Files" error on Linux servers by understanding file descriptors, adjusting limits, and diagnosing leaks effectively.
