SCP, or Secure Copy, is a command-line utility used to copy files and directories between two remote hosts over a secure SSH connection. It is a simple and secure way to transfer files and directories over the internet. In this article, we’ll cover how to copy directories with SCP.
Syntax for Copying
The syntax for copying directories with SCP is as follows:
scp -r [source_directory] [destination_directory]
Here, -r
stands for recursive, which means that the entire directory structure will be copied. [source_directory]
is the directory you want to copy, and [destination_directory]
is the directory where you want to copy it.
Example Copy
Let’s say you want to copy a directory named my_directory
from your local machine to a remote machine with IP address 192.168.0.100
. The command for this would be:
scp -r my_directory user@192.168.0.100:/home/user/
Here, -r
specifies that the entire directory structure of my_directory
will be copied. user
is the username for the remote machine, and /home/user/
is the destination directory on the remote machine where you want to copy my_directory
.
If you want to copy a directory from a remote machine to your local machine, the command would be:
scp -r user@192.168.0.100:/home/user/my_directory my_directory
Here, user
is the username for the remote machine, /home/user/my_directory
is the source directory on the remote machine that you want to copy, and my_directory
is the destination directory on your local machine where you want to copy it.
In conclusion, SCP is a simple and secure way to copy directories between two remote hosts over a secure SSH connection. By understanding the syntax and examples provided above, you can easily copy directories using SCP in your terminal or command prompt.