The basic rule is that Muslims should avoid shaking hands with members of the opposite sex unless they find themselves in an awkward situation. The issue is primarily governed by one’s own conscience.
Sheikh Muhammad Al-Mukhtar Al-Shinqiti, director of the Islamic Center of South Plains, Lubbock, Texas, states the following: There are two common hadiths concerning shaking hands with the opposite sex. In the first hadith, the Prophet (peace and blessings be upon him) is reported to have said, “I do not shake hands with women” (Al-Bukhari).
the second hadith is narrated on the authority of AnasibnMalik (may Allah be pleased with him), he said, “The female slave from Madinah would take hold of the hand of Allah’s Messenger and lead him wherever she wished, without withdrawing her hands from his hands until the Prophet fulfils her need” (Ahmad).
Based on the two hadiths, we conclude that the basic rule discourages shaking hands with members of the opposite sex, but if one were put in an awkward situation, then there would be no harm to shake hands with members of the opposite sex. This ruling applies to Muslims living in the West because of the social customs prevailing in these countries.