The Messenger of Allah ﷺ said, "When one of you enters the mosque, let him pray two units of prayer before sitting down."
أخبرنا قتيبة قال حدثنا مالك عن عامر بن عبد الله بن الزبير عن عمرو بن سليم
أن رسول الله ﷺ قال إذا دخل أحدكم المسجد فليركع ركعتين قبل أن يجلس
Muslim collected it in the Book of the Prayer of Travelers, chapter on the recommendation of greeting the masjid with two rakahs, hadith no. 714, from Qutayba, and Bukhari collected it in the Book of Prayer, chapter on entering the masjid and performing two rakahs, hadith no. 444, through the hadith of Malik with the same chain. It is also found in Muwatta (Yahya narration), 1/162, and in Kubra, hadith no. 809.