Advertisement
Guest User

SSH to gamelift

a guest
Jun 11th, 2021
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. if [ "$#" -ne 1 ]; then
  2. echo "Usage: ./sshhost.sh fleetid"
  3. exit 1
  4. fi
  5.  
  6. FLEET_ID=$1
  7.  
  8. echo Fleet Id is $FLEET_ID
  9.  
  10. aws gamelift update-fleet-port-settings --fleet-id $FLEET_ID --inbound-permission-authorizations FromPort=22,ToPort=22,IpRange=0.0.0.0/0,Protocol=TCP 2> /dev/null
  11.  
  12. INSTANCE_ID=$(aws gamelift describe-instances --fleet-id $FLEET_ID --output text --query 'Instances[0].InstanceId' 2> /dev/null)
  13.  
  14. echo Instance Id is $INSTANCE_ID
  15.  
  16. IP_ADDRESS=$(aws gamelift describe-instances --fleet-id $FLEET_ID --output text --query 'Instances[0].IpAddress' 2> /dev/null)
  17.  
  18. echo IP Address is $IP_ADDRESS
  19.  
  20. rm -rf /tmp/gamelift.pem
  21.  
  22. aws gamelift get-instance-access --fleet-id $FLEET_ID --instance-id $INSTANCE_ID --output text --query 'InstanceAccess.Credentials.Secret' 2> /dev/null | tee /tmp/gamelift.pem
  23.  
  24. chmod 400 /tmp/gamelift.pem
  25.  
  26. echo SSHING to host at $IP_ADDRESS
  27.  
  28. ssh -i /tmp/gamelift.pem gl-user-remote@$IP_ADDRESS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement