. . .

How To Move Files on Servers With Help of SCP Command & Use of SCP Command

Step 1: Copying a file from local machine to a remote server.
# [ scp /path/to/local/file.txt user@remote_server:/path/to/destination/ ]
Replace “/path/to/local/file.txt” with the actual path of the file on your local machine, user with your remote server username, remote_server with the IP address or hostname of the remote server, and “/path/to/destination/” with the destination path on the remote server.

Step 2: Copying a file from a remote server to the local machine.
# [ scp user@remote_server:/path/to/remote/file.txt /path/to/local/destination/ ]
This example retrieves a file from the remote server and saves it to the specified local destination.

Step 3: Copying an entire directory from local to remote.
# [ scp -r /path/to/local/directory/ user@remote_server:/path/to/destination/ ]
The -r flag is used for recursive copying of directories.

Step 4: Copying from remote to local with compression.
# [ scp -C -r user@remote_server:/path/to/remote/directory/ /path/to/local/destination/ ]
The -C flag enables compression during the transfer, which can be useful for large files.

Step 5: Copying multiple files from local to remote.
# [ scp file1.txt file2.txt user@remote_server:/path/to/destination/ ]
You can list multiple source files to be copied.

Step 6: Using a specific SSH key.
# [ scp -i /path/to/private/key.pem /path/to/local/file.txt user@remote_server:/path/to/destination/ ]
Use the -i option to specify the path to your private key.

Note:  a)  Make sure you have the necessary permissions to access the source and destination directories/files.
b) Ensure that SSH is set up on both servers, and you can log in without a password (use SSH keys for secure authentication).
c) Adjust file paths, usernames, and server addresses according to your setup.