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, I seek refuge in You from the punishment of the grave, I seek refuge in You from the evil of the Dajjal, and I seek refuge in You from the trials of life and death."
حدثنا إسماعيل بن عمر قال ثنا مالك عن أبي الزناد عن الأعرج
أن رسول الله ﷺ كان يعلمهم هذا الدعاء كما يعلمهم السورة من القرآن اللهم إني أعوذ بك من عذاب جهنم وأعوذ بك من عذاب القبر وأعوذ بك من شر المسيح الدجال وأعوذ بك من فتنة المحيا والممات
Its isnad is sahih, and it belongs to the musnad of Abu Hurairah, mentioned here for the hadith that follows it.