hey, I've read from a lot of books that kids at that age have "stranger anxiety". Don't force them to greet people. Just talk with your friend naturally then your son will listen for a while. Eventually after this warm up, he will want to join in the conversation. After some time he will figure out there's nothing to be afraid of and will be willing to greet people without any worry. Try it!
my son is 2 yrs 9 months, 2 months ago he still did the same thing as your son, when he saw anyone he just hide behind me or didn't say a word at all. Suddenly he started to say more things from last month and willing to call other people whenever he saw anyone, the most important is everytime before we go out, i will pratice one time with him, tell him we will go out and see maybe grandmom or grandpa, and tell him need to say hello to them and he will remember what i ask him to do then he will say hello to everyone when he see other people, maybe u can try to practice with your son everytime before u go out with him... :lol: