There are several ways of doing this but none of them are good solutions. The way I would probably do it if I had to is like this:
TunnelFrom your machine, tunnel port 222 from your machine to port 22 server Y
ssh -L222:localhost:22 serveryCreateFrom server X, create a dynamic tunnel from server X to server Y using the previously constructed tunnel. Note: your destination on this command is
mymachinebut the credentials you'll use are for server Y since it's what you're actually connecting to.ssh -D8080 -p 222 mymachineSetup server X with a system wide SOCKS Proxy of
localhost:8080