Search code examples
linuxsshgoogle-compute-engine

Ssh port forwarding google compute engine


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?


Solution

  • 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.