The Messenger of Allah ﷺ used to teach them these words for moments of fear, "I seek refuge in the perfect words of Allah from His wrath, from the evil of His servants, from the whisperings of the devils, and from their presence near me."Abdullah bin Umar would teach these words to those of his sons who were old enough to understand, and for those too young to understand, he would write them down and hang them around their necks.
حدثنا موسى بن إسمعيل حدثنا حماد عن محمد بن إسحق
أن رسول الله ﷺ كان يعلمهم من الفزع كلمات أعوذ بكلمات الله التامة من غضبه وشر عباده ومن همزات الشياطين وأن يحضرون وكان عبد الله بن عمر يعلمهن من عقل من بنيه ومن لم يعقل كتبه فأعلقه عليه
Its chain is daif. Tirmidhi transmitted it in the Book of Supplications, chapter on the supplication for fright during sleep, etc., hadith 3528, from the report of Muhammad bin Ishaq with the same wording, and he said, hasan gharib. Hakim graded it sahih in 1/548.Muhammad bin Ishaq is a mudallis and he narrated using an ambiguous form of transmission (anaana).