commands

scp — Copy files over SSH

Copy files with SSH authentication; SFTP is default from OpenSSH 9.0. -P sets port, -p preserves specified timestamps and modes, -r recursively copies. Verify destination and host first; zero indicates success. Use a fresh private workspace; live operations are VM-only.

Formal Syntax & Structure

linux syntaxlinux
scp [OPTIONS] SOURCE DESTINATION

Parameters & Attributes

NameTypeDescription
SOURCEoperandSource path
DESTINATIONoperandDestination path
-PoptionPort
-poptionPreserve times and modes

Return Value

exit status and output

Copy files with SSH authentication; SFTP is default from OpenSSH 9.0. -P sets port, -p preserves specified timestamps and modes, -r recursively copies. Verify destination and host first; zero indicates success.

Working Example

Example Snippetlinux
scp -o StrictHostKeyChecking=yes -o UserKnownHostsFile=./known_hosts source/note.txt learner@lab-server.example:incoming/
Linux Reference