- Create a new ssh key pair in the console or use the one that you already own.
- Generate a ssh public key from the ssh private key (pem > pub)
$ ssh-keygen -y -f ~/.ssh/rainman_key.pem >> ~/.ssh/rainman_public.pub
- Upload the ssh public key to all regions except the one where it exist.then Using python export it. Below is the code:
import os
regions=["us-east-1","us-east-2","us-west-1","us-west-2","ap-east-1","ap-south-1","ap-northeast-2","ap-southeast-1","ap-southeast-2","ap-northeast-1","ca-central-1" ,"eu-central-1","eu-west-1","eu-west-2","eu-west-3","eu-north-1","sa-east-1"]
for region in regions:
os.system("aws ec2 import-key-pair --key-name rainman_key --public-key-material file://rainman_public.pub --region "+region)**