Ssh port forwarding google compute engine

11,840

Solution 1

run the command with the debug flag to help you find more information:

gcloud compute ssh --ssh-flag=-vvv "mini-server-1" \
                   --zone="us-central1-f" \
                   --ssh-flag="-D:5551" \
                   --ssh-flag="-N" \
                   --ssh-flag="-n" &

and as mention in my comment before, use https_proxy.

Solution 2

Much simpler syntax:

gcloud compute ssh my-vm-name --zone=europe-west1-b -- -NL 4000:localhost:4000

You can pass as many options as you want:

-NL 8080:localhost:80 -NL 8443:localhost:443
Share:
11,840
user3057678
Author by

user3057678

Updated on June 15, 2022

Comments

  • user3057678
    user3057678 almost 2 years

    I am trying to forward traffic with google instances but no luck. Here is the scenario: I have 2 instances currently main-server, and mini-server-1 I want to ssh mini-server-1 from main-server and create a dynamic port forwarding like so:

    gcloud compute ssh "mini-server-1" --zone="us-central1-f" --ssh-flag="-D:5551" --ssh-flag="-N" --ssh-flag="-n" &

    I have this error:

    bind: Cannot assign requested address

    I tried: ssh -N username@mini-server-1(all ips internal external, hostname) -D 5551 &

    When i run netstat i can see that ports are free. Here is wget with proxy from main-server

    wget google.com -e use_proxy=yes -e http_proxy=127.0.0.1:5551

    Connecting to 127.0.0.1:5551... connected.
    Proxy request sent, awaiting response...

    Does someone know how can i achieve this?