The legal status of being a hobo is absolutely a precarious one. The main way they would get around is by hopping onto moving freights, specifically because once a train had gotten under steam it would have been very inconvenient for the train to stop to kick off stowaways. Otherwise, they walked (roads generally had public right of way, but cops ignored this).
Vagrancy laws expand dramatically after the Civil War. Vagrancy, as the laws of the time usually stated, was the crime of "having no visible means of support." What this meant was basically up to the enforcing officer, but in the main it was designed to criminalize poverty, with the twist that you probably wouldn't enforce it if your town needed to hire help (e.g. if it were a wheat belt town in Kansas during the harvest), but you would if your town didn't need help (if the hobo arrived a little too late and the wheat was already harvested and threshed). Vagrancy laws were thus a way to selectively criminalize being a hobo.
You get other examples of this as well. Railroads (which the US simply allowed to have cops of their own) had their police go ruthlessly after hobos -- sometimes. The average railroad cop would let a hobo ride westward during the summer, to get out to work. Indeed, the railroad depended on hobos to do their work in order for there to be any wheat to ship later on. But they would throw that same hobo off the train going eastward, because the job was done. The average train cop would expect a bribe from the hobo to stay on the train, since they had presumably earned money working the harvest.
But as with anything in history, groups of people are heterogenous. Some cops were intentionally cruel, taking out their anger, fear, or sadism on hobos. We hear of people being tossed off of trains at speed, or into snowstorms, or someone firing their gun indiscriminately into a boxcar where a hobo was suspected of stowing away. And some cops cultivated a reputation for being particularly harsh on hobos, in order to stop them from coming through the district (at least, that's what the hobos tell us -- I didn't work with cop testimonials to corroborate this!).
Similarly, hobos definitely camped out illegally. They'd usually pick places with good sightlines, where it would be hard to see you but easy to see out -- this often meant taking up shelter in copses of trees, or in nooks between buildings. Usually, they'd try to camp in places near the railroads, especially places where trains would have to slow down (a water tank, or a siding, or an uphill), so they could catch passing freights.
And similarly, those camps would be raided by police, who would sometimes just try to throw them out, but other times would intentionally and cruelly target the necessities of life to try and drive them away permanently -- they would destroy cookware and food, for example. Hobos usually responded to this by hiding those things, so they could come back after the police were gone.
All in all, a very adversarial relationship with the law!