Lecture # 24 - Secure Copy Protocol (SCP)

SCP:

SCP stands for Secure Copy Protocol. It is a network protocol that facilitates secure file transfers between a local host and a remote host or between two remote hosts. SCP is built on top of SSH (Secure Shell) and uses the same authentication and security mechanisms as SSH, ensuring that data transferred via SCP is encrypted and secure. SCP allows users to securely copy files and directories between hosts over a network. It provides a secure alternative to traditional file transfer protocols like FTP (File Transfer Protocol), which transmit data in plain text and are susceptible to eavesdropping and tampering.

Key Features of SCP:

  1. Secure Transfer:

    SCP encrypts all data transmitted between the client and server, ensuring the confidentiality and integrity of the transferred files.

  2. Authentication:

    SCP uses SSH for authentication, allowing users to securely log in to remote hosts using password-based authentication or public key authentication.

  3. Remote File Copy:

    SCP allows users to copy files and directories from a remote host to a local host, from a local host to a remote host, or between two remote hosts.

  4. Recursive Copy:

    SCP supports recursive copying, allowing users to copy entire directories and their contents recursively.

  5. Preservation of File Attributes:

    SCP preserves file attributes such as permissions, timestamps, and ownership during file transfer, ensuring that the copied files maintain their original characteristics.

  6. Cross-Platform Compatibility:

    SCP is supported on various operating systems, including Unix-based systems (such as Linux and macOS) and Windows, making it a versatile tool for file transfer across different platforms.

Copy Files from Windows to AWS EC2 Instance using SCP:

Follow these steps to connect your Windows to the AWS EC2 Instance:

  • Make sure you have an EC2 instance on AWS. If you don't know how to create an EC2 instance view this.

  • Also make sure you know the path where the key of the instance is saved.

  • Select your instance and click on connect.

  • A new window will be opened. Click on SSH client.

  • Copy the command that is selected in the picture.

  • Now go to the location where the SSH key-pair of the instance is saved. Click on the location bar. Write cmd and press enter. A command prompt will be opened.

  • paste the command that was copied and do some changes.

    The copied command was: ssh -i "SSH.pem" ubuntu@ec2-54-167-70-181.compute-1.amazonaws.com . This command is for SSH connection.

    For SCP this command will be: scp -i "SSH.pem" "[file-or-directory-name]" ubuntu@ec2-54-167-70-181.compute-1.amazonaws.com:[path-where-to-copy]

    After making changes in the command press enter.

  • The file is copies to the specified path.

  • Lets go to our EC2 instance and see that the file is copied there or not.

  • The file is copied to our AWS EC2 instance.

  • This is how we copy files or directories from Windows to our AWS EC2 instance using SCP.

0
Subscribe to my newsletter

Read articles from Abdullah Bin Altaf directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Abdullah Bin Altaf
Abdullah Bin Altaf