You can use -R
flag with SOCKS4/5 behavior, this is built-in and it does not require a long command as proposed by @smammy:
[hasinet]$ ssh -R 1080 noinet
You can use the proxy like e.g.
[noinet]$ curl -x socks5h://127.0.0.1:1080 http://www.google.it
This works because the -R
flag will fallback to a SOCK4/5 proxy if no destination host is provided. From man ssh:
-R [bind_address:] port:host:hostport
-R [bind_address:] port
Specifies that connections to the given TCP port or Unix socket on the remote (server) host are to be forwarded to the local side.
This works by allocating a socket to listen to either a TCP port or to a Unix socket on the remote side. Whenever a connection is made to this port or Unix socket, the connection is forwarded over the secure channel,
and a connection is made from the local machine to either an explicit destination specified by host port hostport, or local_socket, or, if no explicit destination was specified, ssh will act as a SOCKS 4/5 proxy and for‐
ward connections to the destinations requested by the remote SOCKS client.
[snip]