Abu Hurairah (RAA) narrated that the Messenger of Allah (ﷺ) said:
"The young should salute the old, the one who is passing by should salute the one who is sitting, and the small group of people should salute the larger one." Agreed upon. In a version by Muslim, "And the one who is riding should salute the one who is walking."
English reference: Book 16, Hadith 1487
Arabic reference: Book 16, Hadith 1443