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 220.127.116.11.
scp /Users/tonyflorida/Desktop/demo-file.zip email@example.com:/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 18.104.22.168 called a-file.txt onto the desktop of your local computer.
scp firstname.lastname@example.org:/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.