Isn't this a solved problem? People have been living in the ISS for years.
The ISS gets the full dose of cosmic rays being outside the atmosphere but those aren't that large a risk. For charged particles the ISS sits inside the inner Van Allen Belt which is the layer of charged particles that have been trapped by Earth's magnetic field. So astronauts are safe from all the high speed electrons and atomic nuclei that you'd have to endure during the day on the Moon's surface.
The Earth's magnetic field gives no distinct advantage to radiation protection if you're already in a thin metal capsule.