Most people are friendly or at least not interested in picking a fight. I concur with those that think fear breeds hostility. Locals have just as much right to fear you as you do them, maybe more so. You're the stranger. Smiling and being friendly makes people let their guard down and be friendly too. People are like dogs. Feeling the need to defend themselves often results in hostility.
I think the biggest danger is at night time and specifically rowdy drunk teenage boys in a small town without much to do. If I feel vulnerable I go out of my way to camp where nobody knows I'm there. If you're not visible then nobody's going to mess with you.