Sunan Ibn Majah, Book 33, Hadith 39 (Ibn Majah 3697)

It was narrated from Abu Hurairah that:

"a man entered the masjid, and the Messenger of Allah(ﷺ) was sitting in a corner of the mosque. He prayed, then he came and greeted him with Salam(peace), and he said: 'Wa 'alaikassalm."