It is narrated from Sayyiduna Ali (may Allah be pleased with him), and Imam Abu Dawud (may Allah have mercy on him) says that (his teacher) al-Hasan bin Ali narrated it as a saying of the Prophet (peace and blessings be upon him): "When a group passes by, it suffices for them that one of them gives the greeting of salam, and for those sitting it suffices that one of them returns it."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب السير / 17946