Quantcast
Channel: single keypair for all regions - Stack Overflow
Viewing all articles
Browse latest Browse all 9

Answer by Network Assasin for single keypair for all regions

$
0
0
  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/rainman_key.pem >> ~/.ssh/rainman_public.pub
  3. 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)**

Viewing all articles
Browse latest Browse all 9

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>