Current models of galaxy formation predict satellite galaxies in groups and clusters that are redder than observed. We investigate the effect on the colours of satellite galaxies produced by the ram pressure stripping of their hot gaseous atmospheres as the satellites orbit within their parent halo. We incorporate a model of the stripping process based on detailed hydrodynamic simulations within the Durham semi-analytic model of galaxy formation. The simulations show that the environment in groups and clusters is less aggressive than previously assumed. The main uncertainty in the model is the treatment of gas expelled by supernovae. With reasonable assumptions for the stripping of this material, we find that satellite galaxies are able to retain a significant fraction of their hot gas for several Gigayears, thereby replenishing their reservoirs of cold, star forming gas and remaining blue for a relatively long period of time. A bimodal distribution of galaxy colours, similar to that observed in SDSS data, is established and the colours of the satellite galaxies are in good agreement with the data. In addition, our model naturally accounts for the observed dependence of satellite colours on environment, from small groups to high mass clusters.