Abu Qatada reported,

I entered the mosque while the Messenger of Allah ﷺ was sitting among the people, so I sat down.The Messenger of Allah ﷺ asked, "What prevented you from praying two units of prayer before sitting down?"I replied, "Messenger of Allah, I saw you sitting and the people sitting, so I sat as well."He said, "When one of you enters the mosque, he should not sit until he has prayed two units of prayer."

Muslim 1655

Sahih

حدثنا أبو بكر بن أبي شيبة حدثنا حسين بن علي عن زائدة قال حدثني عمرو بن يحيى الأنصاري حدثني محمد بن يحيى بن حبان عن عمرو بن سليم بن خلدة الأنصاري

عن أبي قتادة صاحب رسول الله ﷺ قال

دخلت المسجد ورسول الله ﷺ جالس بين ظهراني الناس قال فجلست فقال رسول الله ﷺ ما منعك أن تركع ركعتين قبل أن تجلس قال فقلت يا رسول الله رأيتك جالسا والناس جلوس قال فإذا دخل أحدكم المسجد فلا يجلس حتى يركع ركعتين

مسلم 1655صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Muslim
Book
Travelers' prayer and its shortening
Chapter
Recommendation of greeting the masjid with two rakahs, disliking sitting before praying them, and that it is prescribed at all times
Numbering
Darussalam 1655
Muslim 1655