A Jewish man came to the Prophet ﷺ and his companions and said, "As-samu alaykum (death be upon you)."The people returned the greeting.The Prophet of Allah ﷺ asked, "Do you know what this man just said?"They replied, "Allah and His Messenger know best. Did he not greet us with peace, Prophet of Allah?"He said, "No, he actually said such and such. Bring him back to me."So they brought him back, and the Prophet asked, "Did you say, 'As-samu alaykum'?"The man answered, "Yes."At that, the Prophet of Allah ﷺ said, "When any of the People of the Book greets you, respond by saying, 'And upon you what you have said.'"He then recited, "And when they come to you, they greet you with that with which Allah does not greet you" [Mujadilah 58:8].
حدثنا عبد بن حميد حدثنا يونس عن شيبان عن قتادة
أن يهوديا أتى على النبي ﷺ وأصحابه فقال السام عليكم فرد عليه القوم فقال نبي الله ﷺ هل تدرون ما قال هذا قالوا الله ورسوله أعلم سلم يا نبي الله قال لا ولكنه قال كذا وكذا ردوه علي فردوه قال قلت السام عليكم قال نعم قال نبي الله ﷺ عند ذلك إذا سلم عليكم أحد من أهل الكتاب فقولوا عليك ما قلت قال {وإذا جاءوك حيوك بما لم يحيك به الله}
Agreed upon (by Bukhari and Muslim). Muslim narrated it in the chapter on the prohibition of initiating greetings with the people of the Book, and how to respond to them, no. 2163, from the hadith of Qatada, and Bukhari, no. 6926, from the hadith of Anas, through the same route.