Last active
June 9, 2021 15:05
-
-
Save ronniejoshua/f9bd671cc214b31e0fc3ecd195d64198 to your computer and use it in GitHub Desktop.
Automate external ip white listing and connecting to gcp compute engine using shell script
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 | |
GCLOUD="/Users/<your-username>/google-cloud-sdk/bin" | |
${GCLOUD}/gcloud compute firewall-rules update <gcp-firewall-rule-name> --project=<gcp-project-id> --source-ranges=$(curl ifconfig.me) | |
external_ip=$(${GCLOUD}/gcloud compute instances describe <gcp-compute-engine> --zone=<gcp-ce-zone> --format='get(networkInterfaces[0].accessConfigs[0].natIP)') | |
ssh naya@$external_ip -p 122 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment