Cities of the second class and villages shall have power to require any person, firm, or corporation operating any public water supply in such city or village to connect with and furnish water to such city or village from its mains located within such city or village, and to provide by ordinance for connections of such mains with the mains or portion of water system constructed or operated by such city or village, under such regulations and under such penalties as may be prescribed by ordinance.