It's very dangerous.
Trains shake - a lot. I mean a fucking lot. And they're loud. It takes some skill to deal with that.
Then you've got violent vagrants and drug addicts who you have to deal with who will fuck you up for whatever you have.
Then there is the rail police who don't take kindly to freight hopping. You don't want to end up in county jail for a week because you were found inside of a dirty gondola.
How to do it though? Well, learn the trains. Learn the safety involved (3 points of contact kind of stuff, how to get on/off while it moves etc). Learn the routes...you don't want to end up on a train that isn't going to be stopping for 18 hours when you only have 2 granola bars and a litre of water.
Check out some YouTube channels about it. Brave Dave's Big Fat Freight Hop Part 1 to 4 gives a good PoV from a total newbie, but keep in mind he had help and was doing this in Canada where it's 100000 times safer:
https://www.youtube.com/watch?v=hUg0jFO7NToStobe the Hobo was a famous hopper. He was a very intelligent guy, talented musician and knew everything about the rails but also a drunk and got himself killed doing this:
https://www.youtube.com/@hobestobeHobo Shoestring also does some informative videos, but also rambles a lot:
https://www.youtube.com/@TheHoboShoestringVAGA BOND rides in Russia and post-Soviet countries, but his videos are in English too. Doesn't really teach things, but watching gives you an idea of what goes on:
https://www.youtube.com/@ivantrainsLIVERanOutOnARail has nice videos with minimal narration. If you watch enough, you can learn some tricks but overall the videos are just relaxing with the nice scenery:
https://www.youtube.com/@RanOutOnARailTl;dr don't do it unless you are really fine getting uncomfortable and don't mind potentially going to jail, getting injured or dying. It isn't that fun in reality. The noise and shaking of freight cars is unfathomable if you've never done this and you won't be ready for it.