The Messenger of Allah ﷺ said, and Musa said in his version, according to what Amr reckoned, that the Prophet ﷺ said, "The entire earth is a place of prayer, except for the bathhouse and the graveyard."
حدثنا موسى بن إسمعيل حدثنا حماد ح و حدثنا مسدد حدثنا عبد الواحد عن عمرو بن يحيى عن أبيه
قال رسول الله ﷺ وقال موسى في حديثه فيما يحسب عمرو إن النبي ﷺ قال الأرض كلها مسجد إلا الحمام والمقبرة
Its isnad is sahih. Ibn Majah narrated it in the Book of Mosques, chapter on the places where prayer is disliked, no. 745, from the hadith of Amr bin Yahya, through this route. Tirmidhi mentioned it without a full chain, no. 317. Ibn Khuzayma graded it sahih, no. 791, as did Ibn Hibban, no. 338, 339, and Hakim, according to the criteria of the two Shaykhs, 1/251, and Dhahabi agreed with him.