The hadith you've mentioned can be found in Sahih al-Bukhari (see for example in the book of good manners and forms: al-Adab, in the book of asking permission, in the book of fighting for the cause of Allah (Jihad), in the book of Invocations and in the book of dealing with apostates) and in Sahih Muslim) in several chapters too. Imam al-Bukhari also mentioned it in his al-Adab al-Mufrad. All these narrations might appear with slight differences in the wording.
A simple interpretation of the hadith
The hadith basically is self-explanatory: A group of Jews entered upon the prophet () and instead of greeting him with kind or friendly words they said:
"As-Samu السَّامُ Alaikum." (i.e. death be upon you).
This certainly shows a lot of hostility and unkindness.
His wife and mother of believers 'Aisha () who witnessed and narrated this event answered:
"Wa-Alaikum As-Samu wal-la'n. (death and the curse of Allah be Upon you)."
She basically answered in the same unkind and hostile manner.
But our prophet () here showed and thought her (and us) that one must be kind and lenient in all matters saying:
"Be calm, O `Aisha! Allah loves that on, should be kind and lenient in all matters."
'Aisha returned and asked:
"O Allah's Messenger (ﷺ)! Haven't you heard what they (the Jews) have said?"
As she seemed not to understand how one could be friendly and lenient to such a hostility.
While the prophet confirmed having heard their unkind and unfriendly speech saying:
"I have (already) said (to them) "And upon you !""
The related fiqh discussion
Some scholars use this hadith and many others like:
-
When the Jews offer you salutations, some of them say as-Sam-u-'Alaikum (death be upon you). You should say (in response to it): Let it be upon you. (See for example in Sahih al-Bukhari and Sahih Muslim)
-
"If the people of the Scripture greet you, then you should say (in reply), 'Wa'alaikum (And on you).' " (See for example in Sahih al-Bukhari and Sahih Muslim)
-
Do not greet the Jews and the Christians before they greet you and when you meet any one of them on the roads force him to go to the narrowest part of it. (Sahih Muslim)
to show that we should neither initiate the greeting and nor answer the greeting of non-Muslims by "Wa alaikum as-Salam" (and peace be upon you) even if they actually said something that sounds like "As-Salamu السَّلاَمُ 'alaikum" and should which them the same that they wished us by saying: "And upon you" or "the same to you".
The hanafi scholar al-'Ayni said and quoted in his commentary on Sahih al-Bukhari (called 'Omdat al-Qari عمدة القاري see for example here) the following:
In the following I'm translating from Arabic language as these translations are mine take them carefully!
ذهب عَامَّة السّلف وَجَمَاعَة الْفُقَهَاء أَن أهل الْكتاب لَا يبدأون بِالسَّلَامِ، حاشى ابْن عَبَّاس، وصدي ابْن عجلَان وَابْن محيريز فَإِنَّهُم جوزوه ابْتِدَاء..
The salaf in general and a group of scholars of jurisprudence held the opinion that one shouldn't start greeting the people of the book with "as-Salam". Except with ibn 'Abbas, Suday ibn 'iIjlaan and ibn Muhayriz1 who allowed initiating the greeting.
1: a Tabi'y (follower of the sahabah) from a-Shaam.
he added:
وَذهب آخَرُونَ إِلَى جَوَاز الِابْتِدَاء للضَّرُورَة أَو لحَاجَة تعن لَهُ إِلَيْهِ أَو لذمام أَو نسب، وروى ذَلِك عَن إِبْرَاهِيم وعلقمة،
Others said that initiating the greeting is allowed in case of necessity or need in which one depends on that person like protection and kinship among those who said so are Ibrahim and 'Alqamah.
He then added more of the discussion and evidences of each side on initiating the greeting saying:
Note that copy pasting from Arabic caused a digit transposition in the verse number!
وَقَالَ الْأَوْزَاعِيّ: إِن سلمت فقد سلم الصالحون، وَإِن تركت فقد ترك الصالحون، وتؤول لَهُم قَوْلهم: لَا تبتدؤهم بِالسَّلَامِ، أَي: لَا تبتدأوهم كصنيعكم بِالْمُسْلِمين.
Al-Awza'y said: if you greeted then the faithfuls have done so, and if you left it the faithfuls have left it too. And he interpreted the statement of the hadith: don't greet them before they greet as "do like they do with Muslims.
وَاخْتلفُوا فِي رد السَّلَام عَلَيْهِم فَقَالَت طَائِفَة: رد السَّلَام فَرِيضَة على الْمُسلمين وَالْكفَّار، قَالُوا: وَهَذَا تَأْوِيل قَوْله تَعَالَى: { فَحَيوا بِأَحْسَن مِنْهَا وردوها} ( النِّسَاء: 68) .
قَالَ ابْن عَبَّاس وَقَتَادَة فِي آخَرين: هِيَ عَامَّة فِي الرَّد على الْمُسلمين وَالْكفَّار.
And they differed (in opinion) about answering the greeting of non-Muslims. Some said: answering a greeting is Fard on Muslims and non-Muslims and this is what is referred to by "greet [in return] with one better than it or [at least] return it [in a like manner]" (4:86)
وَقَوله: { أَو ردوهَا} ( النِّسَاء: 68) .
يَقُول للْكَافِرِ: وَعَلَيْكُم.
قَالَ ابْن عَبَّاس: من سلم عَلَيْك من خلق الله تَعَالَى فاردد عَلَيْهِ، وَإِن كَانَ مجوسياً.
As for "or [at least] return it [in a like manner]" (4:86)
One says to the non-Muslim " and upon you".
Ibn 'Abbas said: Whoever greets you from Allah's creation answer him. Even if he was a magi.
وروى ابْن عبد الْبر عَن أبي أُمَامَة الْبَاهِلِيّ أَنه كَانَ لَا يمر بِمُسلم وَلَا يَهُودِيّ وَلَا نَصْرَانِيّ إلاَّ بدأه بِالسَّلَامِ. وَعَن ابْن مَسْعُود وَأبي الدَّرْدَاء وفضالة بن عبيد أَنهم كَانُوا يبدأون أهل الْكتاب بِالسَّلَامِ،
Ibn 'Abd al-Barr narrated fom abu Umamah al-Bahili that he never passed by a Muslim nor Jew nor Christian without greeting him (first). And ibn Mas'ud, abu a-Dardaa' and Fadala ibn 'Ubaid2 that they used to initiate greeting the people of the book.
وَكتب ابْن عَبَّاس إِلَى كتابيَّ: السَّلَام عَلَيْك. وَقَالَ : لَو قَالَ لي فِرْعَوْن خيرا لرددت عَلَيْهِ،.
And ibn 'Abbas wrote to a person from among the people of the book: "As-Salamu 'alaika".
And he said: "If Fir'aun (Pharao) spoke to me in a friendly manner I'd answer him".
وَقيل لمُحَمد بن كَعْب: إِن عمر بن عبد الْعَزِيز يرد عَلَيْهِم وَلَا يبدأوهم، فَقَالَ مَا أرى بِإِنْسَان يبدأهم بِالسَّلَامِ، لقَوْل الله تَعَالَى: { فاصفح عَنْهُم وَقل سَلام} ( الزخرف: 98) ..
And it was said to Muhammad ibn Ka'ab that 'Umar ibn 'Abdal'aziz used to answer their greetings but not start greeting them. he answered I don't see any harm in initiating the greeting because Allah the Almighty says: "So turn aside from them and say, "Peace."" (43:89)
2: all the four of them were sahabah.
So far the view of those who say there's no harm in initiating the greeting to non-Muslims. He also quoted the views and evidences of those who hold an opposite view:
وَقَالَت طَائِفَة: لَا يرد السَّلَام على الْكِتَابِيّ، وَالْآيَة مَخْصُوصَة بِالْمُسْلِمين، وَهُوَ قَول الْأَكْثَرين، وَعَن ابْن طَاوُوس، يَقُول: علاك السَّلَام، وَاخْتَارَ بَعضهم أَن يردعَلَيْهِم السَّلَام بِكَسْر السِّين، أَي: الْحِجَارَة، وَعَن مَالك: إِن بدأت ذِمِّيا على أَنه مُسلم ثمَّ عرفت أَنه ذمِّي فَلَا نسترد مِنْهُ السَّلَام،.
Another group said: one doesn't answer the greeting (more exactly: as-Salam) of the people of the book and the verse is special for Muslims and this is the view of most scholars. Ibn Tus said: "Alaika as-Salam" while others chose to change the vocal after the letter "Seen" saying "Alaika as-Silam" (as-Silam: are stones or rocks in Arabic).
It was narrated from imam Malik: If one initiated the greeting to a Dhimi thinking he was a Muslim we don't revoke the greeting "As-Salam".
وَقَالَ ابْن الْعَرَبِيّ: وَكَانَ ابْن عمر، رَضِي الله تَعَالَى عَنْهُمَا، يسْتَردّهُ مِنْهُ فَيَقُول: أردد عَليّ سلامي.
Ibn al'Araby said that ibn Umar may Allah be pleased with both of them used to revoke it from a Dhimi ordering him: "Answer my Salam!"
One must be aware that most of these statements are based on the premise that these non-Muslims are a weak minority under Muslim rulership. In fact most of the ahdaith are compiled in chapters or subsections on Dhimi's or enemies.
Also note that the following fatwa on islamqa #26785 (apparently only available in Arabic) denies that the prophet () or the sahabah actually applied the last hadith (from Sahih Muslim) literally, but it explains that if Muslims meet non-Muslims on the road they should stay together as a group and don't let the non-Muslims go through them so it by no means mean one should use force or hinder a person from walking the same line or road.
See also: Salam to non-Muslims