Tuesday, February 11, 2025

Error: importing EC2 Key Pair (ssh-key): operation error EC2: ImportKeyPair in to AWS EC2

Error: importing EC2 Key Pair (ssh-key): operation error EC2: ImportKeyPair, https response error StatusCode: 400, RequestID: 7ef58acb-c106-44ff-a96b-ea7c92c81f18, api error InvalidParameterValue: Value for parameter PublicKeyMaterial is invalid. Length exceeds maximum of 2048.

Solution:

You are trying to import a private key.  You need to extract the public key.  

Here is how you create the key:  ssh-keygen -t rsa -b 2048 -C "name@domain.com" -f ~/ssh-key.pem

Now to remove the public key run: ssh-keygen -y -f ~/ssh-key.pem > ~/ssh-key-pub.pem

It'll now import!


Source: Link

No comments:

Post a Comment

ShareThis