The Messenger of Allah ﷺ used to teach them this supplication just as he would teach them a surah from the Quran, "O Allah, I seek refuge in You from the punishment of Hell, and from the punishment of the grave, and I seek refuge in You from the trial of the Messiah, the Dajjal, and I seek refuge in You from the trials of life and death."
حدثنا الأنصاري حدثنا معن حدثنا مالك عن أبي الزبير المكي عن طاوس اليماني
أن رسول الله ﷺ كان يعلمهم هذا الدعاء كما يعلمهم السورة من القرآن اللهم إني أعوذ بك من عذاب جهنم ومن عذاب القبر وأعوذ بك من فتنة المسيح الدجال وأعوذ بك من فتنة المحيا والممات
Muslim also narrated it in the Book of Mosques, chapter "What Should Be Sought Refuge From During Prayer," hadith no. 590, through Malik with the same wording, and it is found in Muwatta 1/215.