Laws for armed maitime guards

Hey im new
Seen a lot about the ship guards for pirates,how do these guys go through ports on deployment?
is there some kind of special visa?