Intro🧑‍💻

紀錄有哪些方式可以ssh到gce機器

  1. 放key到中繼資料 Compute Enging -> 中繼資料 -> 安全殼層金鑰

  2. 使用TCP Tunneling

gcloud compute start-iap-tunnel --project project-id --zone vm-zone --local-host-port 127.0.0.1:10001 vm-host 22
  1. 使用gcloud ssh
gcloud compute ssh --zone vm-zone vm-host --tunnel-through-iap --project project-id

可編寫tunnel的script

## dev
gcloud compute start-iap-tunnel dev-border 22 --local-host-port 127.0.0.1:10120 --zone asia-east1-b --project gcp-project &

## test
gcloud compute start-iap-tunnel test-border 22 --local-host-port localhost:10121 --zone asia-east1-b --project gcp-project &

## prod
gcloud compute start-iap-tunnel prod-border 22 --zone asia-east1-b --local-host-port 127.0.0.1:10122  --project gcp-project &

Reference