From e0fdee5e793fbf28f2fa1c9b600879d3c063b259 Mon Sep 17 00:00:00 2001 From: Jakub Gawlik <60949037+caasi-dev@users.noreply.github.com> Date: Thu, 20 May 2021 23:14:35 +0100 Subject: [PATCH] correct file ref when using --public-ket-material It seems that with the new aws-cli when using --public-key-material flag to import SSH key, we need to use `fileb` instead of `file`. As it stands currently, import will report *An error occurred (InvalidKey.Format) when calling the ImportKeyPair operation: Key is not in valid OpenSSH public key format*. According to this issue: https://github.com/aws/aws-cli/issues/4969#issuecomment-592278206 `fileb` seems to resolve the problem. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index aa91d61..80ae0d9 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ keypair_name="rattlesnakeos" ssh-keygen -t rsa -b 4096 -f ${keypair_name} for region in $(aws ec2 describe-regions --query "Regions[*].RegionName" --output text); do echo "Importing keypair ${keypair_name} to region ${region}..." - aws ec2 import-key-pair --key-name "${keypair_name}" --public-key-material "file://${keypair_name}.pub" --region $region + aws ec2 import-key-pair --key-name "${keypair_name}" --public-key-material "fileb://${keypair_name}.pub" --region $region done ```