How to SCP Linux

Using SCP in Linux to Transfer Files with PEM Authentication

Secure Copy Protocol (SCP) is a command-line tool used for securely transferring files between local and remote systems. In this article, we will explore how to use SCP in Linux while employing a PEM file for authentication. We will also demonstrate how to transfer files to a remote Ubuntu server using the “ubuntu” user account and placing the files in the “/home/ubuntu” directory.

Before proceeding with the SCP commands, ensure that you have the following:

  1. A Linux distribution installed on your local machine.
  2. The PEM file associated with the remote server you wish to connect to.
  3. The IP address of the remote server.
  4. The username and directory path on the remote server where you want to copy the files.


  • For remote servers, use the public IP address.
  • For local servers within the same network, use the private IP address.

Let’s dive into the step-by-step process of using SCP with PEM authentication.

Step 1: Open a Terminal
To begin, open a terminal window on your local Linux machine.

Step 2: Set Permissions for the PEM File
Before using the PEM file for authentication, you need to ensure that the file has the correct permissions. In most cases, the permissions should be set to 400 (read-only for the owner).

chmod 400 /path/to/your/pem/file.pem

Step 3: Transfer Files Using SCP
With the necessary permissions set, you can now use SCP to transfer files to the remote server. The basic syntax for the SCP command is as follows:

scp -i /path/to/your/pem/file.pem /path/to/local/file user@remote_ip:/path/on/remote/server

Replace the placeholders with the relevant information:

  • /path/to/your/pem/file.pem: The path to the PEM file on your local machine.
  • /path/to/local/file: The path to the file you wish to transfer.
  • user: The username for the remote server (in this case, “ubuntu”).
  • remote_ip: The IP address of the remote server (e.g., public IP for remote servers or private IP for local servers).
  • /path/on/remote/server: The directory path on the remote server where you want to copy the files (e.g., “/home/ubuntu”).


Let’s say you have a file named “example.txt” located in your home directory (“/home/yourusername/example.txt“). You want to transfer it to the “/home/ubuntu” directory on the remote server at IP address, using the “ubuntu” user account and the provided PEM file.

The SCP command would look like this:

scp -i /path/to/your/pem/file.pem /home/yourusername/example.txt ubuntu@

Once you run the command, SCP will securely transfer the file to the specified remote server directory.

In this article, we covered the process of using SCP in Linux to transfer files while utilizing PEM authentication. We outlined the necessary steps, including setting the correct permissions for the PEM file and executing the SCP command. By following these instructions, you can securely transfer files to a remote server using SCP in a Linux environment. Remember to use the appropriate IP address (public or private) depending on whether you are connecting to a remote server or a local server within the same network.

Leave a comment