I like the little rare earth magnets for fastening things down. I do find that I have to key and epoxy them so that they stay put over time. If in doubt, a little vaseline on the O-ring would not go amiss.
Another choice that may be even better, as mentioned by Dodgy Geezer, is to use silicone to make a gasket in place.