The Messenger of Allah ﷺ said, "These privies are frequented by jinn, so when one of you enters, let him say, 'O Allah, I seek refuge in You from male and female devils.'"Jamil bin al-Hasan al-Ataki narrated to us, Abdul-Ala bin Abdul-Ala narrated to us, Saeed bin Abu Aruba narrated to us from Qatada. And Harun bin Ishaq narrated to us, Abdah narrated to us, he said Saeed narrated to us from Qatada, from Qasim bin Awf al-Shaybani, from Zayd bin Arqam, that the Messenger of Allah ﷺ said, and he mentioned the hadith.
حدثنا محمد بن بشار حدثنا محمد بن جعفر وعبد الرحمن بن مهدي قالا حدثنا شعبة عن قتادة عن النضر بن أنس
قال رسول الله ﷺ إن هذه الحشوش محتضرة فإذا دخل أحدكم فليقل اللهم إني أعوذ بك من الخبث والخبائث حدثنا جميل بن الحسن العتكي حدثنا عبد الأعلى بن عبد الأعلى حدثنا سعيد بن أبي عروبة عن قتادة ح و حدثنا هارون بن إسحق حدثنا عبدة قال حدثنا سعيد عن قتادة عن القاسم بن عوف الشيباني عن زيد بن أرقم أن رسول الله ﷺ قال فذكر الحديث
Its isnad is sahih. Abu Dawud narrated it in Kitab al-Taharah, Chapter on what a man says when he enters the toilet, no. 6, from the hadith of Shubah, through this route, and Ibn Khuzayma, Ibn Hibban, Hakim, and Dhahabi graded it sahih.