Running Google Cloud’s “gcutil” behind a socks proxy with socks and ssh tunnel

Grupodot
Comments Off on Running Google Cloud’s “gcutil” behind a socks proxy with socks and ssh tunnel

Suppose you have to use google’s cloud platform “gcutil” tool to connect to one or more nodes on a project hosted on google cloud platform but you don’t have a direct internet connection although you still can set up a ssh connection to a gateway who has the ability to connect directly to Internet. Given this scenario you can follow this simple steps to accomplish your task:

1. Open a terminal and ssh to your gateway using the following command

ssh -D 1080 user@gateway_ip

2. Install tsocks package (Debian/Ubuntu or RedHat/CentOS)

sudo apt-get install tsocks
or
yum install tsocks

3. Edit your tsocks.conf file like this:

# your local network/mask
local = 192.168.100.0/255.255.255.0
# local = 10.0.0.0/255.0.0.0
# Paths
# For this example this machine needs to access 150.0.0.0/255.255.0.0 as 
# well as port 80 on the network 150.1.0.0/255.255.0.0 through
# the socks 5 server at 10.1.7.25 (if this machines hostname was 
# "socks.hello.com" we could also specify that, unless --disable-hostnames
# was specified to ./configure).
path {
 reaches = 150.0.0.0/255.255.0.0
 reaches = 150.1.0.0:80/255.255.0.0
 server = localhost
 server_type = 5
 default_user = delius
 default_pass = hello
}
# Default server
# For connections that aren't to the local subnets or to 150.0.0.0/255.255.0.0
# the server at 192.168.0.1 should be used (again, hostnames could be used
# too, see note above)
# your local ssh-socks server
server = 127.0.0.1
# Server type defaults to 4 so we need to specify it as 5 for this one
server_type = 5
# The port defaults to 1080 but I've stated it here for clarity 
# the port you'd just select in the previous ssh connection
server_port = 1080

4. Launch gcutil

tsocks ./gcutil node-id

And that’s all.