Make a station with a faction, create a rail with a permission block attached to the station granting access to unfactioned ships.
Dock an unfactioned ship to the station, make sure to add a turret dock to said ship
Dock a turret to the ship, once you leave the turret (hopefully) you will find that the turret has adopted the station's faction.
//This can be undone by undocking the ship from the station.//
I apologise for not providing extra information regarding Java version and server info, I do not know how to get the information.