So the Prophet (ṣallallāhu ʿalayhi wa sallam) would seek refuge from Shayṭān by saying:
“Aʿūdhu billāhi al-samīʿi al-ʿalīmi min al-shayṭāni al-rajīm, min hamzihi wa nafkhihi wa nafthih.”
That is: I seek refuge in Allah, the All-Hearing, the All-Knowing, from the accursed Shayṭān—from his promptings, his puffing and his spitting.
(Abū Dāwūd: Book of Prayer; al-Tirmidhī)
That is why the Prophet (ṣallallāhu ʿalayhi wa sallam) would take Allah’s name before beginning every important task—that is, begin with ‘Bismillāh’—because the remembrance of Allah drives Shayṭān away. He also used to make this supplication:
اللَّهُمَّ إِنِّي أَعُوذُ بِكَ مِنْ الْهَدْمِ وَأَعُوذُ بِكَ مِنْ التَّرَدِّي وَأَعُوذُ بِكَ مِنْ الْغَرَقِ وَالْحَرَقِ وَالْهَرَمِ وَأَعُوذُ بِكَ أَنْ يَتَخَبَّطَنِي الشَّيْطَانُ عِنْدَ الْمَوْتِ وَأَعُوذُ بِكَ أَنْ أَمُوتَ فِي سَبِيلِكَ مُدْبِرًا وَأَعُوذُ بِكَ أَنْ أَمُوتَ لَدِيغًا
That is: O Allah, I seek refuge in You from being crushed by a falling wall, from falling from a height, from drowning, from burning and from the frailty of old age. I seek refuge in You lest Shayṭān touch me at the time of my death, lest I die fleeing from Your path (in jihad), and lest I die of a snakebite.
(Abū Dāwūd: Book of Witr)
When he was frightened in his sleep, he would recite this supplication:
أَعُوْذُ بِكَلمَاتِ اللهِ التَّامَّةِ مِنْ غَضَبِهِ وَعِقَابِهِ وَشَرِّ عِبَادِهِ وَمِنْ هَمَزَاتِ الشَّيْطَانِ وَأَنْ يَحْضُرُوْنَ
That is: I seek refuge in the perfect words of Allah from His anger and His punishment, from the evil of His servants, from the promptings of the devils, and lest they come near me.
(Aḥmad 2/181; Abū Dāwūd: Book of Medicine; al-Tirmidhī: Book of Supplications)