How to forward a server socket to a (possibly ssh) client

view story

http://serverfault.com – I'm wondering if/how I can realize the following setup. It doesn't seem to fit the standard ssh port forwarding model. I have a client machine A. I have a server application running on machine A, which listens on port X. However, machine A is behind a common IP-address (shared by many users) so it can't receive incoming connections to port X from the internet. However, I have access to a machine, B, in Amazon EC2 and it would be OK connections would go through that machine. It's not possible to move the application to this machine in EC2. Hence, what I want, is to have machine B listen on po (HowTos)