Is sharing your ports with other players legal?
Ports/harbors enhance the maritime trade. This is a trade between one player and the bank. You can only use maritime trade during your turn. So it is not possible to offer port services to other players.

From the rules:


  You can also trade without the other players! During your turn, you can always trade at 4:1 by putting 4 identical resoirce cards back in their stack and taing a 1 resource card of your choice for it. If you have a settlement or city on a harbor, you can trade with the bank more favorably: at either 3:1 ratio or, in certain harbors, at 2:1 (trading resource type shown).


However, you can trade the turn of the player owning the port in several steps. Using your example (Player A wants to trade 3 sheep for an ore with player B who does not have an ore yet.


On his turn, Player B trades a wood (or an other non sheep/ore) for two sheep with player A.
Player B uses his port to trade two sheep for one ore.
Player B trades the ore for the sheep and the wood.  


The effect is the same. It is only possible on the turn of the player owning the port