When people greet one another, they approach straight on, look one another in the eye, and shake hands. It turns out that with dogs, approaching them this way makes them think you're going to kill them. To worsen the situation, when you rub them on the back of the neck, they're waiting for you to bite into their flesh because in the wild, that's where they would be attacked.
Fearful dogs can be unpredictable and, at times, aggressive dogs. The best way to approach you canine is to kneel down and scratch its ears and chest, building trust and an inseparable bond.
Source: http://drsophiayin.com/blog/entry/how-to-greet-a-dog