How to add multiple keys for elastic beanstalk instance?

前端 未结 8 1337
青春惊慌失措
青春惊慌失措 2020-12-23 17:05

There is a very good question on [How to] SSH to Elastic [an] Beanstalk instance, but one thing I noticed is that, through this method, it is only possible to add one SSH ke

8条回答
  •  不思量自难忘°
    2020-12-23 17:18

    instead of running echo and storing your keys on Git, you can upload your public keys to IAM user's on AWS and than do:

    commands:
      copy_ssh_key_userA: 
        command: rm -f /home/ec2-user/.ssh/authorized_keys;aws iam list-users --query "Users[].[UserName]" --output text | while read User; do aws iam list-ssh-public-keys --user-name "$User" --query "SSHPublicKeys[?Status == 'Active'].[SSHPublicKeyId]" --output text | while read KeyId; do aws iam get-ssh-public-key --user-name "$User" --ssh-public-key-id "$KeyId" --encoding SSH --query "SSHPublicKey.SSHPublicKeyBody" --output text >> /home/ec2-user/.ssh/authorized_keys; done; done;
    

提交回复
热议问题