All Products
Search
Document Center

Elastic Compute Service:View public key information

Last Updated:Mar 26, 2024

If you want to use the same SSH key pair to log on to multiple Elastic Compute Service (ECS) instances or allow multiple SSH key pairs to access the same ECS instance, you must obtain the public key information of the SSH key pairs to perform the required configurations. You can use the following methods to view and obtain the public key information. This topic describes how to view and obtain the public key information of an SSH key pair that is bound to an ECS instance.

On-premises Windows device

To view public key information, perform the following operations:

  1. Start PuTTYgen.

  2. Click Load.

  3. Select the .ppk or .pem file.

    PuTTYgen displays the public key information.

On-premises Linux or macOS device

Run the ssh-keygen command in which the path of the .pem file is specified.

ssh-keygen -y -f /path_to_key_pair/my-key-pair.pem

The following example shows the returned public key information:

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABA****+GF9q7rhc6vYrExwT4WU4fsaRcVXGV2Mg9RHex21hl1au77GkmnIgukBZjywlQOT4GDdsJy2nBOdJPrCEBIPxxxxxxxxxx/fctNuKjcmMMOA8YUT+sJKn3l7rCLkesE+S5880yNdRjBiiUy40kyr7Y+fqGVdSOHGMXZQPpkBtojcxxxxxxxxxxx/htEqGa/Jq4fH7bR6CYQ2XgH/hCap29Mdi/G5Tx1nbUKuIHdMWOPvjxxxxxxxxxx+lHtTGiAIRG1riyNRVC47ZEVCxxxxxx
Note

If the command fails, run the chmod 400 my-key-pair.pem command to change the permissions to ensure that only you can view the file.

View public key information within an instance

  1. Connect to the Linux instance.

    For more information, see Connect to a Linux instance by using a password or key.

  2. Run the following command to view the public key information of an SSH key pair:

    sudo cat ~/.ssh/authorized_keys
    Note

    The public key information is stored in the ~/.ssh/authorized_keys file. Open the file on the instance to view the public key information.

References

After you obtain the public key information of an SSH key pair, you can perform the following operations: