حَدَّثَنَا مُحَمَّدُ بْنُ عُثْمَانَ الدِّمَشْقِيُّ، حَدَّثَنَا عَبْدُ الْعَزِيزِ، - يَعْنِي الدَّرَاوَرْدِيَّ - عَنْ رَبِيعَةَ بْنِ أَبِي عَبْدِ الرَّحْمَنِ، عَنْ عَبْدِ الْمَلِكِ بْنِ سَعِيدِ بْنِ سُوَيْدٍ، قَالَ سَمِعْتُ أَبَا حُمَيْدٍ، أَوْ أَبَا أُسَيْدٍ الأَنْصَارِيَّ يَقُولُ قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏"‏ إِذَا دَخَلَ أَحَدُكُمُ الْمَسْجِدَ فَلْيُسَلِّمْ عَلَى النَّبِيِّ صلى الله عليه وسلم ثُمَّ لْيَقُلِ اللَّهُمَّ افْتَحْ لِي أَبْوَابَ رَحْمَتِكَ فَإِذَا خَرَجَ فَلْيَقُلِ اللَّهُمَّ إِنِّي أَسْأَلُكَ مِنْ فَضْلِكَ ‏"‏ ‏.‏
Translation
Haiwah b. Shuraih reported

I met ‘Uqbah b. Muslim and said to him: it has been reported to me that someone has narrated to you from the prophet (ﷺ) that when he entered the mosque, he would say: I seek refuge in Allah, the Magnificent, and in His noble face, and in his eternal domain, from the accursed Devil. He asked : is it so much only? I said: Yes. He said: when anyone says so. The devil says: he is protected from me all the day long.