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/

Comments are closed.

Niklas Tech Blog
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.