SCP Examples

I’m always forgetting what parameters to use and in what order I should use them. Here is some examples to help me find what I’m looking for.

Syntax:
scp options from to

Copy one file from a computer to another with standard settings. The file will end up in my home directory on computerB:

scp filename user@computerB.com:.

Copy one file from computerA to computerB with port 222. The file will end up in /tmp on the computerB

scp -P 222 filename user@computerB.com:/tmp

Copy a folder from computerA to computerB. The folder and all its content will end up in my home directory in a folder called Backup

scp -r foldername user@computerB.com:Backup/

Copy one file from computerB to computerA. The file is in my home directory on computerB. The file will end up in my current directory on computerA

scp user@computerB.com:filename .

Copy a folder from computerB to computerA. The folder is found here /tmp/Backup on computerB and will end up in my home directory in a folder called tmp.

scp -r user@computerB.com:/tmp/Backup /home/user/tmp/

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">

This site uses Akismet to reduce spam. Learn how your comment data is processed.