The Messenger of Allah ﷺ used to teach them this supplication just as he taught them a surah from the Quran. He would say, "Say, O Allah, we seek refuge in You from the punishment of Hell, and I seek refuge in You 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 narrated it in his Sahih, Book of Mosques, the chapter on what one seeks refuge from during prayer, hadith no. 590, from Qutayba through the same chain. It is also found in Muwatta (Yahya), 1/215, and in Kubra, hadith no. 2190, in 1/215.