public
Last active

shell script for starting and logging onto an ec2 instance

  • Download Gist
start-logon-ec2.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#!/bin/bash
 
secGroup="sg-50681d39"
ami="ami-1aad5273"
keyName="ec2ApiTools"
keyLocation="/home/jal/Documents/AWS/ec2ApiTools_rsa_id"
 
instance_id=$(ec2-run-instances -k $keyName -g $secGroup -t m1.large $ami | awk '/INSTANCE/{print $2}')
echo $instance_id
 
sleep 30
 
name=$(ec2-describe-instances $instance_id | awk '/INSTANCE/{print $4}')
echo $name
 
ssh -i $keyLocation ubuntu@$name -o StrictHostKeyChecking=no

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.