Introduction
Secure Copy Protocol (SCP) is a fast and secure way to transfer files between Unix-like systems. It uses Secure Shell (SSH) to transfer data and provides strong authentication and secure encrypted communications. This tutorial will guide you through the process of transferring files between servers using SCP. Since SCP uses SSH to secure the process, once SSH is set up and enabled, we can easily use SCP to transfer files between servers.
Prerequisites
- Familiarity with the server address, username, and password or SSH keys for authentication.
- Access to two servers with SCP installed and configured.
Step 1 – Connect to the server
Before using SCP, make sure you have SSH access to both servers. To establish an SSH connection, open a terminal and use the SSH command to connect to the server:
ssh username@server_ip
رمز عبور را ارائه دهید یا از کلید SSH خود برای احراز هویت استفاده کنید. پس از اتصال، آماده استفاده از SCP هستید.
Step 2 – Use scp to transfer single and multiple files
Transfer a single file
To transfer a file from your device to the server:
scp /path/to/local/file username@server_ip:/path/to/remote/directory
برای انتقال از سرور به دستگاه خود:
scp username@server_ip:/path/to/remote/file /path/to/local/directory
انتقال چندین فایل
For multiple files from:
scp -r /path/to/local/directory username@server_ip:/path/to/remote/directory
Step 3 – Check the files
After the transfer, check the integrity of the files:
- Connect to the destination server: Use SSH to log in to the server where the files were transferred.
- Navigate to directory: Change to the directory where the files were uploaded.
- File list: from
lsOrls -lUse to view files and their details. - Check file integrity: Optionally, compare file sizes or use checksums (e.g. using
md5sum) to make sure the files are intact.
Result
In this tutorial, you learned how to transfer files between servers using SCP. SCP provides a secure and efficient way to transfer files, and with these simple steps, you can easily move files between servers securely. It is an invaluable tool for system administrators and anyone who needs to securely transfer data across a network. Remember, always verify the integrity of your files after transferring them to make sure they are complete and not corrupted.









