CmdID

CmdID / aws / aws iam

aws iam get-ssh-public-key

Retrieves the specified SSH public key, including metadata about the key. AWS CLI reference

2 examples 3 options Its page in the AWS CLI reference

Opens CmdID with your command. It is read in your browser and sent nowhere.

Examples

from aws-cli, each command read by CmdID

Example 1: To retrieve an SSH public key attached to an IAM user in SSH encoded form

The following get-ssh-public-key example retrieves the specified SSH public key from the IAM user sofia. The output is in SSH encoding.

aws iam get-ssh-public-key --user-name sofia --ssh-public-key-id APKA123456789EXAMPLE --encoding SSHIdentify
--user-nameThe name of the IAM user associated with the SSH public key.
--ssh-public-key-idThe unique identifier for the SSH public key.
--encodingSpecifies the public key encoding format to use in the response.
Its output
{
    "SSHPublicKey": {
        "UserName": "sofia",
        "SSHPublicKeyId": "APKA123456789EXAMPLE",
        "Fingerprint": "12:34:56:78:90:ab:cd:ef:12:34:56:78:90:ab:cd:ef",
        "SSHPublicKeyBody": "ssh-rsa <<long encoded SSH string>>",
        "Status": "Inactive",
        "UploadDate": "2019-04-18T17:04:49+00:00"
    }
}

Example 2: To retrieve an SSH public key attached to an IAM user in PEM encoded form

The following get-ssh-public-key example retrieves the specified SSH public key from the IAM user sofia. The output is in PEM encoding.

aws iam get-ssh-public-key --user-name sofia --ssh-public-key-id APKA123456789EXAMPLE --encoding PEMIdentify
--user-nameThe name of the IAM user associated with the SSH public key.
--ssh-public-key-idThe unique identifier for the SSH public key.
--encodingSpecifies the public key encoding format to use in the response.
Its output
{
    "SSHPublicKey": {
        "UserName": "sofia",
        "SSHPublicKeyId": "APKA123456789EXAMPLE",
        "Fingerprint": "12:34:56:78:90:ab:cd:ef:12:34:56:78:90:ab:cd:ef",
        "SSHPublicKeyBody": "-----BEGIN PUBLIC KEY-----\n<<long encoded PEM string>>\n-----END PUBLIC KEY-----\n",
        "Status": "Inactive",
        "UploadDate": "2019-04-18T17:04:49+00:00"
    }
}

For more information, see Use SSH keys and SSH with CodeCommit in the AWS IAM User Guide.

Options

3 in the AWS CLI reference
--encodingSpecifies the public key encoding format to use in the response.
--ssh-public-key-idThe unique identifier for the SSH public key.
--user-nameThe name of the IAM user associated with the SSH public key.