Skip to content

Instantly share code, notes, and snippets.

@jibs
Created April 25, 2015 15:57
Show Gist options
  • Save jibs/0579c58d9972e65a506b to your computer and use it in GitHub Desktop.
Save jibs/0579c58d9972e65a506b to your computer and use it in GitHub Desktop.
port forwarding with a google cloud instance

Google cloud's ssh command lets you pass standard ssh flags. To, for example, forward local port 8088 to port 8088 on a vm instance, all you need to do is:

gcloud compute  ssh --ssh-flag="-L 8088:localhost:8088"  --zone "us-central1-b" "example_instance_name"

Now browsing to localhost:8088 works as it would with standard ssh.

@srflp
Copy link

srflp commented Nov 22, 2022

Windows:

gcloud compute ssh vm-instance-name `
 --project project_name `
 --zone zone `
 --ssh-flag="-L 8080:localhost:8080"

Linux/macOS:

gcloud compute ssh vm-instance-name \
 --project project-name \
 --zone zone \
 -- -NL 8080:localhost:8080

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment