Recursively copy a local directory to a remote host with SCP
Build a paste-ready command, then review its compatibility and effects before running it.
scp -r -P 22 <local-directory> <username>@<host>:<remote-path>Complete required fields to copy the generated command.
Compatibility
Linux + macOSVerified for Linux, macOS using posix, bash, zsh syntax.
Operational knowledgereview due 2027-01-19
Requirementsscpscp must be installed and available on PATH.Network accessThe target must be reachable from the current environment.
Version supportscp Current supported releasesVerified for linux, macos using posix, bash, zsh syntax; consult compatibility notes for platform-specific differences.
Expected signalsindex.html 100% 8421 1.2MB/s 00:00Representative successful output; values vary with the selected target and system state.
Known errorsscp: command not foundscp is missing or is not available on PATH.
Verifyscp -r -P {{port}} {{localDirectory}} {{user}}@{{host}}:{{remotePath}}Re-run the corresponding read-only inspection and confirm the intended state.Rollback noteNo universal automatic rollback is available. Capture the current state and use the tool-specific recovery procedure before applying changes.
Command breakdown
01scpCommandRuns the scp stage of this one-liner.
02-rOptionRecursively copies the selected directory and its descendants.
03-POptionConnects to the SSH server on the specified port.
04<port>ParameterA value supplied in the Fill parameters section.
05<local-directory>ParameterA value supplied in the Fill parameters section.
06<username>@ParameterA value supplied in the Fill parameters section.
07<host>:ParameterA value supplied in the Fill parameters section.
08<remote-path>ParameterA value supplied in the Fill parameters section.
Example input
scp -r -P 22 site/ deploy@app01.example.com:/srv/www/
Example output
index.html 100% 8421 1.2MB/s 00:00
app.css 100% 18KB 3.4MB/s 00:00
app.js 100% 126KB 12.1MB/s 00:00
Illustrative output — exact values vary by system and data.
Official sources
Related commands