Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk3 min

Download a Remote Directory Recursively with OpenSSH SFTP

Run get -R /remote/path ./local-destination at the sftp prompt to download a whole remote directory. Here are the flags, path rules, and symlink and resume limits to know.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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

  1. Start the session from your local terminal, for example sftp [email protected]. If the server listens on a non-default port, put -P port before the destination, such as sftp -P 2222 [email protected].
  2. At the sftp> prompt, run pwd to see the remote working directory and lpwd to see the local one. Using fully qualified remote paths avoids mistakes about where a relative path resolves.
  3. 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.
  4. 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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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 -a and reget assume 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 -P and 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 -a or reget.

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

Bestseller No. 4
SSH/SFTP Server - Terminal Server
SSH/SFTP Server - Terminal Server
Wireless File Transfer; Full functional SSH Server; SFTP File Transfer; Protect USB charging port
Bestseller No. 5
SSH/SFTP Server for TV
SSH/SFTP Server for TV
Wireless File Transfer; Full functional SSH Server; SFTP File Transfer; Protect USB charging port
$6.99
Best Value
SSH/SFTP Server for TV
  • Wireless File Transfer
  • Full functional SSH Server
  • SFTP File Transfer
  • Protect USB charging port
  • Multiple users with multiple paths
Rank #4
SSH/SFTP Server - Terminal Server
  • Wireless File Transfer
  • Full functional SSH Server
  • SFTP File Transfer
  • Protect USB charging port
  • Multiple users with multiple paths

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.Support on Ko-Fi

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.