The Messenger of Allah ﷺ said, "The one riding should greet the one walking, the one walking should greet the one sitting, and the smaller group should greet the larger group. Whoever returns the greeting, the reward is his, and whoever does not return it gets nothing."
قال رسول الله ﷺ: يسلم الراكب على الراجل، والراجل على الجالس، والأقل على الأكثر، فمن أجاب السلام كان له، ومن لم يجب فلا شيء له.
Ahmad (4/16566) and Bukhari in Adab al-Mufrad (992) both narrated it from the hadith of Yahya bin Abu Kathir, from Zayd bin Salam, from his grandfather, who said that Muawiya wrote to Abdul-Rahman bin Shibl, telling him to teach the people what he had heard from the Messenger of Allah ﷺ. So he gathered them and said, "I heard the Messenger of Allah ﷺ say," then he related the hadith.This is how Ahmad presented it, while Bukhari narrated only the part attributed directly to the Prophet ﷺ.