Chapter: It is recommended to greet the masjid by praying two rak`ah, and it is disliked to sit before praying these two rak`ah, and this is prescribed at all times
Ka'b b. Malik reported: The Messenger of Allah ( صلی اللہ علیہ وسلم ) did not come back from the journey but by day in the forenoon, and when he arrived, he went first to the mosque, and having prayed two rak'ahs in it he sat down in it.
Authentic