Answer:
Normally the initial electrical source comes from a battery or series of. Some vessels have a sort of large power cord called a "shore tie". A great many vessels have generators of various size onboard to run electrical equipment. There are solar powered vessels and vessels that derive their power from small "windmills" on the mast.