Transferring files or folders between servers can be a time-consuming process, especially when you have large amounts of data to move. Fortunately, if you have shell access to both servers, you can use the Secure Copy (SCP) command to transfer files and folders quickly and securely.
The basic syntax of the SCP command is as follows:
scp -r <username>@<ip_address>:<source_path> <destination_path>
Let's break down each element of the command:
<username>: This is the username for a valid user on the source server.
<ip_address>: This is the IP address or hostname of the source server where the files or folders are located.
<source_path>: This is the path to the files or folders that you want to copy on the source server.
<destination_path>: This is the path where you want to copy the files or folders on the destination server.
Note that the -r flag is used to copy directories and their contents recursively. If you're only copying a single file, you can omit this flag.
Once you've entered the command, you'll be prompted to enter the password for the source server. After you've entered the correct password, the file transfer will begin, and you'll see a progress bar indicating the status of the transfer. When the transfer is complete, you'll see a prompt to indicate that the transfer has finished.
Here's an example command to copy a directory called "my_folder" from a server with IP address 192.168.1.100 to the current directory on the local machine:
scp -r firstname.lastname@example.org:/home/user/my_folder .
In this example, we're using the dot (.) to specify the current directory as the destination path. If you want to specify a different destination path, you can replace the dot with the appropriate directory path.
By using the SCP command, you can easily transfer files and folders between servers without having to download and upload the data manually. This can save you a lot of time and effort, especially when you're working with large amounts of data.