Were they trying to "jack me"?
The whole idea behind shaking hands is to show you are not armed - goes back centuries. If someone grabs your right hand, you can't reach a weapon, even if you have one, without some delay. A similar ploy is to ask for a light (cigarette). You were right to stand off. The circumstances would put me in the "orange alert" mode or higher. When approached with an inappropriate request, I tell them to "move on" - and prepare to take more affirmative action.