Quantcast
Viewing latest article 3
Browse Latest Browse All 9

Answer by Diego Roberto Dos Santos for single keypair for all regions

If you want to create a ssh key pair in the AWS Console and upload this key pair to all other regions.

  1. Create a new ssh key pair in the console or use the one that you already own.

  2. Generate a ssh public key from the ssh private key (pem > pub)

    $ ssh-keygen -y -f ~/.ssh/MySSHKeyPair.pem >> ~/.ssh/MySSHKeyPair.pub

  3. Upload the ssh public key to all regions. (remove from the list the region that already have the ssh key)

    $ for region in us-east-1 us-east-2 us-west-1 us-west-2 ap-south-1 ap-northeast-2 ap-southeast-1 ap-southeast-2 ap-northeast-1 eu-central-1 eu-west-1 eu-west-2 ; do aws ec2 import-key-pair --key-name MySSHKeyPair --public-key-material file://~/.ssh/MySSHKeyPair.pub --region $region ; done

  4. Get the list of all ssh key pairs in all regions.

    $ for region in us-east-1 us-east-2 us-west-1 us-west-2 ap-south-1 ap-northeast-2 ap-southeast-1 ap-southeast-2 ap-northeast-1 eu-central-1 eu-west-1 eu-west-2 ; do aws ec2 describe-key-pairs --region $region ; done


Viewing latest article 3
Browse Latest Browse All 9

Trending Articles