Last active
July 14, 2021 08:52
-
-
Save katzefudder/a43878b515442a8ae1d04b1a3ca2ca70 to your computer and use it in GitHub Desktop.
Open a terminal/ssh session on each ec2 instance available in your AWS region with this oneliner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
aws ec2 describe-instances --region eu-west-1 --filter Name=tag:Name,Values=InstanceName --query 'Reservations[].Instances[].PrivateIpAddress' --output text | xargs -I {} gnome-terminal -x ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ~/my_keys/my-private-key.pem -o IdentitiesOnly=yes cloud-user@{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws ec2 describe-instances --region eu-west-1 --output text --query 'Reservations[].Instances[].PublicIpAddress' | xargs -I {} osascript -e 'tell app "Terminal" to do script "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ~/my_keys/my-private-key.pem -o IdentitiesOnly=yes cloud-user@{}"' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws ec2 describe-instances --region eu-west-1 --output text --query 'Reservations[].Instances[*].InstanceId' --filters Name=instance-state-name,Values=running | xargs -L 1 -I {} osascript -e 'tell app "Terminal" to do script "aws ssm start-session --target {}"' |
nice catch, thanks!
jq
removed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Maybe remove dependency to jq
aws ec2 describe-instances --region eu-west-1 --query "Reservations[].Instances[].PrivateIpAddress" --output text