When I first started experimenting with photography and taking photos, besides not knowing what I was doing, I was much more timid when it came to getting portrait photos of strangers. There's been times when I've seen photographers somewhat sneak-attack people to get a close-up shot without asking for permission. I don't agree with that technique as it feels a lot like an invasion of someone's privacy, even if they are in a public space.
Nowadays when I'm traveling, I generally try to get some portraits of the local people. Usually a simple smile and that universal gesture you develop to convey the fact that you want to take their photo will do. Some people will turn you down, and that's ok. It's not worth upsetting someone who doesn't want their photo taken when there'll be plenty of people who are perfectly happy with it. After all, if a tourist/photographer kindly asked or motioned to take your photo, are you going to go along with it or would you be unhappy? How unhappy would you be if someone tried to surprise you at the last second by snapping your photo?
Common sense and judgement, with a friendly smile usually go along way. One more thing to keep in mind, in more conservative countries it can be considered offensive to take photos of the locals without their permission. In some countries, it can be quite hard to take photos of women due to conservative or religious beliefs. Even so, I've always found friendly people that were happy to have their photo taken as long as you are respectful.