Accessing SFTP via proxy

The first time in my carrier I had to access SFTP from a server w/o direct access to Internet! Sure thing I had to use proxy. But it took me a while to find a workable solution:

sftp -oProxyCommand="nc -X connect -x your_proxy:port %h %p" username@hostname

Google suggests a lot of strange tools like proxy-connect, connect etc. But nothing of that is available in CentOS! For the sake of truth I should mention that proxy has to be configured correctly. In my company Ops guys use Squid which by default forbids everything except HTTP/HTTPS! So they had to tune it a bit to allow port 22.

PS. One guy told me I could use SSH as SOCKS proxy! I found this interesting article describing that in details…