Praise be to Allaah.
This is false and has no basis of truth, because the Prophet (peace and blessings of Allaah be upon him) died as decreed by Allaah and as Allaah said (interpretation of the meaning):
“Verily you (O Muhammad) will die and verily, they (too) will die” [al-Zumar 39:30]
According to a saheeh hadeeth, the Prophet (peace and blessings of Allaah be upon him) said: “Allaah has angels who travel about in the earth and convey to me the salaams of my ummah.”
And he (peace and blessings of Allaah be upon him) said: “There is no one who sends salaams upon me but Allaah will restore my soul to me so that I may return his salaam.”
And he (peace and blessings of Allaah be upon him) said: “The best of your days is Friday, so send more blessings (salaah) upon me on that day, for your blessings will be shown to me.” They said, “O Messenger of Allaah, how will they be shown to you when you (your body) have disintegrated?” He said, ‘Allaah has forbidden the earth to consume the bodies of the Prophets.”
And there are many ahaadeeth which say similar things, but it is not narrated anywhere that the Prophet (peace and blessings of Allaah be upon him) said that he would shake hands with anybody. This indicates that this story is false. Even if we were to assume that it is true, then it could be that that was a shaytaan (devil) who shook hands with him in order to deceive him and lead him and others astray. What all Muslims have to do is to fear Allaah and to adhere to His sharee’ah which is indicated in His Book and in the Sunnah of His trustworthy Messenger, and to beware of anything that goes against that. May Allaah reform the Muslims and grant them understanding of His religion and cause them to adhere to His sharee’ah, for He is the Most Generous, Most Kind.