How To Use The scp Command to Copy a File From Remote to Local (and vice versa)

SCP secure copy tutorial

Hey there! Some links on this page may be affiliate links which means that, if you choose to make a purchase, I may earn a small commission at no extra cost to you. I greatly appreciate your support!

In this tutorial, you will learn how to securely copy a file from your local computer to a remote server and also vice versa from a remote server to your local computer. This can be done on any operating system that has a built-in terminal including Mac and Linux. If you are on Windows, you can use pscp to copy files to and from a remote server.

How to Copy Files from Local to Remote with SCP

In your terminal window, execute the following command to copy a local file called demo-file.zip into the /root/ directory of a remote server with IP address of 66.42.85.9.

scp /Users/tonyflorida/Desktop/demo-file.zip root@66.42.85.9:/root/demo-file.zip

After hitting Enter, type or paste in the password when it prompts you. The file will then be uploaded to the remote server.

How to Copy Files from Remote to Local with SCP

In the command prompt, execute the following command to copy a remote file on server with IP address of 66.42.85.9 called a-file.txt onto the desktop of your local computer.

scp root@66.42.85.9:/root/a-file.txt /Users/tonyflorida/Desktop/a-file.txt

After hitting Enter, type or paste in the password when it prompts you. The file will then be downloaded to your local computer.

YouTube video

Facebook
Twitter
Pinterest
LinkedIn
Reddit

Meet Tony

Tony from Tony Teaches Tech headshot

With a strong software engineering background, Tony is determined to demystify the web. Discover why Tony quit his job to pursue this mission. You can join the Tony Teaches Tech community here.

Leave a Reply

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