The rider should first greet the pedestrian, and the pedestrian the one who is seated and a small group should greet a larger group (with as-Salam-u-'Alaikum). (Using translation from Muslim 2160)
قَالَ رَسُولُ اللهِ ﷺ يُسَلِّمُ الرَّاكِبُ عَلَى الْمَاشِي وَالْمَاشِي عَلَى الْقَاعِدِ وَالْقَلِيلُ عَلَى الْكَثِيرِ