To download a whole remote directory with OpenSSH SFTP, open an SFTP session and run get -R /remote/path/to/directory ./local-destination at the sftp> prompt. The -R flag makes get retrieve the directory tree recursively. The command is documented in OpenBSD’s current sftp(1) manual, which lists the syntax as get [-afpR] remote-path [local-path]. The steps below cover the connection, the flags that change what gets copied, and the limits you should know before relying on the transfer.
Run the recursive download step by step
- Start the session from your local terminal, for example
sftp [email protected]. If the server listens on a non-default port, put-P portbefore the destination, such assftp -P 2222 [email protected]. - At the
sftp>prompt, runpwdto see the remote working directory andlpwdto see the local one. Using fully qualified remote paths avoids mistakes about where a relative path resolves. - Run
get -R /remote/path/to/directory ./local-destination. Choose a local destination your account can write to and that has enough free space for the whole tree. - If you need the original file permissions and access times on the copies, add
-p:get -pR /remote/path/to/directory ./local-destination.
What each option changes
Several options look similar but do different jobs. The uppercase and lowercase forms of the same letter are not interchangeable, so check the case before you run a command.
As an Amazon Associate I earn from qualifying purchases.
| Option | Where it goes | Effect | Use it when |
|---|---|---|---|
-P port |
On the sftp command line, before the destination |
Selects the connection port | The server does not listen on the default port |
-R |
On get (or reget), before the remote path |
Retrieves a directory and its contents recursively | You want a whole directory tree, not one file |
-p |
On get, alongside -R if needed |
Preserves transferred file metadata, including permissions and access times | The copies must match the originals’ permissions and timestamps |
-a |
On get |
Attempts to resume a partial transfer | An earlier transfer stopped and the local partial copy is intact |
reget |
As its own command | Resumes a download; equivalent to get with -a and accepts -R for recursive use |
You prefer a dedicated resume command over get -a |
Choose the local path carefully
The local path argument is optional. If you omit it, the retrieved content uses the same name as the remote path. If the remote path matches more than one file, the local path you give must be an existing directory. A single-file argument has no such restriction, so a mistake that works for one file can fail for a pattern that expands to several.
Free tools Windows power users keep installed
One-click scans. No signup required.
Know the limits before you rely on the copy
- Symbolic links are not followed. Recursive transfers skip symlinks, so content reachable only through a link may be missing from the local copy. Check the local tree against the remote one if links are part of the data.
- Resuming needs a matching partial file.
get -aandregetassume the local partial copy matches the remote file. If the contents differ, the manual warns that the result is likely corrupt. Delete the partial file and restart the transfer when you are unsure. - Server and account rules still apply. The client manual cannot confirm that your account can read a given directory, or that a particular server offers SFTP. Authentication, file permissions, and server configuration decide whether the command succeeds, so a failure may come from the server side rather than the syntax.
Troubleshooting checklist
- The session fails to connect: confirm the port with
-Pand that the server accepts SFTP for your account. - The download stops with access errors: confirm your account can read every subdirectory under the remote path, not only the top level.
- The copy is missing files you expected: check for symbolic links in the remote tree, since they are skipped during recursive transfer.
- A multi-file download fails on the local path: create the destination directory first and pass it as the local path.
- A resumed file looks wrong: discard the partial local copy and run the transfer again without
-aorreget.
The behaviour described here comes from the OpenBSD sftp(1) manual as it stood on 2026-10-07. Option handling can differ in older OpenSSH releases and in other SFTP clients, so run man sftp on your own system if the command rejects an option.
Quick Recap
Best Value
- Wireless File Transfer
- Full functional SSH Server
- SFTP File Transfer
- Protect USB charging port
- Multiple users with multiple paths
Rank #4
- Wireless File Transfer
- Full functional SSH Server
- SFTP File Transfer
- Protect USB charging port
- Multiple users with multiple paths
Rank #3
Rank #2
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.




