Bootstrap FreeKB - Amazon Web Services (AWS) - Delete EC2 key pair using the AWS CLI
Amazon Web Services (AWS) - Delete EC2 key pair using the AWS CLI


This assumes you have already configured the aws command line tool. If not, check out my article on Getting Started with the AWS CLI.

The aws ec2 describe-key-pairs command can then be used to list the EC2 key pairs that have been created.

~]$ aws ec2 describe-key-pairs
{
    "KeyPairs": [
        {
            "KeyPairId": "key-0551234a925abcd7a",
            "KeyFingerprint": "86:0e:bb:db:6b:78:7c:67:0e:b1:91:38:0a:ce:95:71:4d:2b:72:2e",
            "KeyName": "default",
            "KeyType": "rsa",
            "Tags": []
        },
        {
            "KeyPairId": "key-04582539453c591c1",
            "KeyFingerprint": "b6:eb:8a:a0:5e:4e:a6:0b:66:3c:3d:93:6d:42:63:d7:f5:32:23:71",
            "KeyName": "my-key",
            "KeyType": "rsa",
            "Tags": []
        }
    ]
}

 

The aws ec2 delete-key-pair command can be used to delete a key pair using the name of the key pair.

aws ec2 delete-key-pair --key-name my-key

 

Or using the ID of the key pair.

aws ec2 delete-key-pair --key-pair-id key-04582539453c591c1

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 113b5a in the box below so that we can be sure you are a human.