Skip to content

Instantly share code, notes, and snippets.

@mrdotb
Last active March 29, 2018 15:31
Show Gist options
  • Save mrdotb/94a8f7a07fe696a577ebb5e8d4f91718 to your computer and use it in GitHub Desktop.
Save mrdotb/94a8f7a07fe696a577ebb5e8d4f91718 to your computer and use it in GitHub Desktop.
create ssh_config file from google compute engine project
gcloud config set project $PROJECT_ID
gcloud compute instances list --format json | jq -M '.[] | select(.status == "RUNNING") | "Host \(.name)\n hostname \(.networkInterfaces[0].accessConfigs[0].natIP)\n user $USER\n port $SSH_PORT\n"' | sed 's/\\n/\n/g' | sed 's/"//g' > ssh_config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment