running sshd on a differnet port
I have two different networks, A and B and need to be able to connect from A to B over the open internet.
A is behind a firewall, B is behind a different firewall.
In my first attempt I configured the router at B to forward port 22 to a particular machine running sshd on port 22. I was then able to ssh from A to the machine on B.
Recently I have noticed an increased level of traffic hitting port 22 on the B router, so I decided to move the ssh service to a different, random port.
I reconfigured the router and sshd, and was able to ssh from the open internet to B, but I could not ssh from firewalled network A to B. The log from the router at B shows the incoming traffic on the correct port, but my ssh client doesn't give me a login prompt.
How does sshd respond to an incoming request? Does it answer on port 22, or on the port the request comes in on? If it answers on the port that it is running on, then that port is blocked by firewall A just now, and I wouldn't hear back from the server? Is there a way around this?