You can enjoy free mobile roaming in Europe, but when travelling by train the onboard Wi-Fi may be the best way to get online. It can offer a faster and more reliable connection than mobile signals, which will often drop out as you travel around the continent at high speed.
But as with any public Wi-Fi service, there are some security risks to be considered. The articles below can help you take measures in order to protect yourself while using public Wi-Fi networks, whether it's on the train, in a ho(s)tel, or in a coffee shop.
Article on Wired: Simple Steps to Protect yourself on Public Wi-Fi.
Article on Interrail Planner: Staying safe when using public Wi-Fi while interrailing.