Al-Bukhari and Muslim, as well as others, also narrated it through other routes from Abu al-Tayyah, from Anas, in a similar wording. It is included in Sahih Abi Dawud (478).
It has a corroborating report in the hadith of Umm Salamah, who said:
“I have never forgotten what he said on the day of the Trench, while he was handing them mudbricks, with the hair of his chest covered in dust. He was saying: ‘O Allah, indeed all good is the good of the Hereafter; so forgive the Helpers and the Emigrants.’”
Then, when he saw Ammar, he said:
“Woe to the son of Sumayyah! He will be killed by the rebellious party.”
Ahmad (6/289), Abu Yaʿla (3/209/1645), and Abu Nuʿaym in al-Hilyah (3/43) narrated it through Ibn ʿAwn, from al-Hasan, from his mother, from her.
I say: This is an authentic chain of transmission according to Muslim’s criteria. Muslim included in his Sahih (8/186) only the incident concerning Ammar, and Ahmad also narrated it—contrary to what the annotator of Musnad Abi Yaʿla gives the impression of, when he attributed it to Muslim and al-Tayalisi, whereas neither of them contains the hadith in question.
As for the phrase, “Indeed all good is the good of the Hereafter,” al-Bukhari narrated it in al-Adab al-Mufrad (no. 346) through Abu Ghalib, from Umm al-Dardaʾ, who said:
“Salman visited us, travelling on foot from al-Madaʾin to Syria, wearing a cloak and an andarward”—that is, trousers gathered up at the ankles. Ibn Shawdhab said: Salman was seen wearing a cloak that covered his head and hung down over his ears—that is, he had a dishevelled appearance. He was told, “You have made yourself look ugly!” He replied, “Indeed all good is the good of the Hereafter.”
I say: This is a good chain of transmission. Its narrators are reliable, though there is slight criticism concerning Abu Ghalib—the companion of Abu Umamah—which does not lower his hadith below the rank of good.