How do you use scp command with an example?

The scp (Secure Copy Protocol) command is used to securely transfer files between a local host and a remote host or between two remote hosts. It uses SSH for data transfer, providing the same authentication and security as SSH.

Here’s an example of how to use the scp command:

scp /path/to/local/file.txt user@remote_host:/path/to/remote/directory/

In this example:

  • /path/to/local/file.txt is the path to the file you want to copy from your local machine.
  • user is your username on the remote machine.
  • remote_host is the IP address or domain name of the remote machine.
  • /path/to/remote/directory/ is the directory on the remote machine where you want to place the copied file.

Make sure that the SSH service is running on the remote machine and that you have the necessary permissions to access the directories involved.


scp command secure copy file transfer SSH Linux command