It shall be lawful for the sheriff or a police officer, to search any vessel for deserters, criminals, or other offenders, without a warrant, on producing to the commanding officer of the vessel the sheriff’s or police officer’s commission or appointment as sheriff or police officer; and the commanding officer of a vessel who refuses any sheriff or police officer, access to the vessel or any part thereof shall be fined not less than $10 nor more than $1,000.