If you can­not use a SSH client to bypass the fire­wall (403 error, con­nect com­mand not allowed) you can use GNU http­tun­nel to bypass the fire­wall. I per­son­ally use http­tun­nel to bypass TRANSPARENT FIREWALLS.

As an exam­ple we for­ward again the Win­dows Remote Desk­top (port 3389).

We use the same sce­nario as in the SSH 3 arti­cle:
There is a Remote­Server in a large com­pany behind a Fire­wall. You own the Mid­dle­Server, a pub­lic avail­able SSH server. Last but not least there is your Work­sta­tion — you want to con­trol the Remote­Server from this machine.

Mid­dle­Server:
Start HTTP­tun­nel on Mid­dle­Server, for­ward port 80 (incom­ing) to local SSH Port:

1
# hts –forward-port localhost:22 80

Remote­Server:
Start HTTP­tun­nel client, for­ward local port 900 to Mid­dle­Server port 80 (make sure your Web Server is NOT running!):

1
# htc –forward-port 900 –proxy HTTPProxy:8080 MiddleServer:80

News, 18.10.2006:
———————–
New w32 pack­age avail­able, change log:
–com­piled with lat­est cygwin1.dll (v1.5.21)
–includ­ing lat­est cvs ver­sion
–included debug builds (for sta­ble and cvs build)

[ad#AdBrite-Text]

Get the updated ver­sion: Down­load GNU http­tun­nel Win­dows bina­ries (v3.3)r2.
Get the old ver­sion: Down­load GNU http­tun­nel Win­dows bina­ries (v3.3).

As GNU http­tun­nel traf­fic is not encrypted we cre­ate a SSH tun­nel in our http­tun­nel tun­nel…:Again we use the same set­tings for our Putty sessin as in the SSH 3 article:

On the Remote­Server, start a SSH ses­sion to the Mid­dle­Server. Change to the “Tun­nels Tab” and enter the REMOTE for­warded port:

BUT the SSH server is of course localhost:900 (through the httptunnel).

Now start a ses­sion from your Work­sta­tion to the MiddleServer:

And now fire-up the Ter­mi­nal Server Client (mstsc.exe):

Now you con­trol the Remote­Server with­out change any fire­wall rules…

Its impor­tant that you can use only 1 http­tun­nel per port! Another Hint: the log­ging goes to the Win­dows appli­ca­tion log!

IMPORTANT: http­tun­nel does NOT sup­port NTLM proxy authentification!

Another exam­ple:
Server (Linux):

1
# ./hts –no-daemon –D4 –forward-port localhost:22 80

Client (Win­dows):

1
> htc –no-daemon –D4PPROXYSERVER:8080 –F 8888 YOUR-PUBLIC-SERVER:80

When you use debu­glevel you migth see those keep-alive messages:

1
2
3
4
5
6
7
8
9
tunnel_write_request: TUNNEL_PAD1
tunnel_read_request:  TUNNEL_PAD1
poll() timed out
tunnel_write_request: TUNNEL_PAD1
tunnel_read_request:  TUNNEL_PAD1
poll() timed out
tunnel_write_request: TUNNEL_PAD1
tunnel_read_request:  TUNNEL_PAD1
poll() timed out

After x sec­onds, the con­nec­tion will close and re-establish itself:

1
2
3
4
5
6
7
8
9
10
11
12
13
tunnel_write_request: con­nec­tion > 300 sec­onds old
tunnel_write_request: clos­ing old con­nec­tion
tunnel_out_disconnect: warn­ing: bytes=4278 != content_length=102400
tunnel_out_disconnect: out­put dis­con­nected
tunnel_out_setsockopts: non-fatal SO_SNDLOWAT error: Pro­to­col not avail­able
tunnel_out_setsockopts: non-fatal SO_SNDLOWAT: 0
tunnel_out_setsockopts: SO_LINGER: onoff=1 linger=2000
tunnel_out_setsockopts: non-fatal TCP_NODELAY: 1
tunnel_out_setsockopts: SO_KEEPALIVE: 1
http_write_request: POST
http://1.2.3.4:80/index.html?crap=1161192374 HTTP/1.1
tunnel_out_connect: out­put con­nected
tunnel_write_request: TUNNEL_PAD1

From the httport faq:
Q: When I use SSH (or VNC, or ) over GNU http­tun­nel, the pro­gram locks up after a few min­utes (or hours). When I close the pro­gram and attempt to recon­nect, SSH times out. What’s wrong?
A: Your http­tun­nel con­nec­tion has failed on the client end (pos­si­bly due to net­work con­ges­tion), but the server end has not rec­og­nized that the con­nec­tion has been lost and won’t allow another con­nec­tion until the first con­nec­tion times out. To estab­lish a more sta­ble tun­nel, try exper­i­ment­ing with the var­i­ous options for the htc and hts pro­grams. The fol­low­ing set­tings seem to work pretty well for me, but your mileage may vary:

1
2
3
hts –S –max-connection-age 20000 –F localhost:22 8890

htc –F 8890 –strict-content-length –B 5k –max-connection-age 2000 –P proxy.mycompany.com:8080 10.1.1.1:8890

Links:
http://www.nocrew.org/software/httptunnel/faq.html (GNU http­tun­nel faq)
http://www.nocrew.org/software/httptunnel.html (GNU http­tun­nel home)
http://sebsauvage.net/punching/ (GNU http­tun­nel how-to)