You tax the operator of the train or ship. They will presumably pass on this cost to their customers as they do with any other fixed cost such as boat maintenance, crew salaries, port fees etc.
The beauty is, you don't even have to tax the operator directly, as long as the train is traveling between countries participating in the same scheme. The fuel (or power) the train uses has already been taxed, as has the production of the train itself.