Let me explain the configuration. There are three machines (1) my laptop (2) my PC behind the NAT (3) my aws instance with public address. I'm trying to access (2) from (1).
I did this:
pc$ ssh -R 2222:localhost:20 aws_user@aws_ip
Now I can do the following.
laptop$ ssh aws_user@aws_ip
aws$ ssh -p2222 pc_user@localhost
That's perfect. However I cannot ssh from my laptop to the PC through my bridge machine (aws). Like this.
laptop$ ssh -2531 pc_user@aws_ip
ssh: connect to host aws_ip port 2222: Connection refused
netstat -a spills the following:
tcp 0 0 localhost:2222 *:* LISTEN
tcp 0 0 localhost:48164 localhost:2222 ESTABLISHED
tcp 0 0 localhost:2222 localhost:48164 ESTABLISHED
tcp6 0 0 ip6-localhost:2222 [::]:* LISTEN
And all the ports are open on the aws machine. The following failed as well.
ssh -R 2222:*:22
I'm answering the question myself. The GatewayPorts needed to be turned on.
add GatewayPorts yes