The Messenger of Allah ﷺ said, "The rider greets the one walking, the one walking greets the one seated, and the smaller group greets the larger group."
قال رسول الله ﷺ: يسلم الراكب على الماشي، والماشي على القاعد، والقليل على الكثير.
Bukhari narrated it in the Book of Seeking Permission (6232-6233), and Muslim in the Book of Greetings (2160), both through routes from Ibn Jurayj, who said, Ziyad told me that he heard Thabit, the freed slave of Abdul-Rahman bin Zayd, say that he heard Abu Hurairah say it, as mentioned.