The Messenger of Allah ﷺ said, "When one of you comes to the mosque, let him pray two units of prayer before sitting down."
حدثنا قتيبة بن سعيد حدثنا مالك بن أنس عن عامر بن عبد الله بن الزبير عن عمرو بن سليم الزرقي
قال رسول الله ﷺ إذا جاء أحدكم المسجد فليركع ركعتين قبل أن يجلس
Agreed upon (by Bukhari and Muslim). Muslim also recorded it in the Book of the Prayer of Travelers, Chapter on the Recommendation of Greeting the Masjid with Two Rakahs, etc., no. 714, from Qutayba, and Bukhari, no. 444, through the hadith of Malik, and it is in Muwatta 1/162 (Yahya's version).There are also narrations on this subject from Jabir bin Abdullah Ansari [Bukhari, no. 931, and Muslim, no. 875], Abu Umama [Ahmad 5/255], Abu Hurairah [Ibn Majah, no. 1012], Abu Dharr [Ibn Hibban, no. 322], and Kaab bin Malik [Bukhari, no. 3088, and Muslim, no. 2769, at length].