Tunneling SSH through multiple machines (for SOCKS)

view story

http://unix.stackexchange.com – I have seen questions on tunnelling SSH through multiple machines but I want to tunnel a SOCKS connection. Normally I would use something like ssh -C2qTnN -D 8080 username@remote_machine to make the local port 8080 a SOCKS tunnel through the remote machine. I would like to open a socks connect from my laptop on machine2, that can only be reached via SSH from machine1. So rather than tunnelling SSH connections in the normal sense, I suppose I wish to run that command on machine1 so the local port 8080 is redirected to machine2 and somehow pipe 8080 on machine1 back to a local port on laptop. (HowTos)