Whenever he, meaning the Prophet ﷺ, retired to his bed, he would place his right hand under his cheek and say, "My Lord, protect me from Your punishment on the Day You resurrect," or "gather Your servants."
كان-يعني النبي ﷺ- إذا أوى إلى فراشه وضع يده اليمنى تحت خده وقال: رب قني عذابك يوم تبعث- أو تجمع- عبادك.
Tirmidhi (3398) and Ahmad (23244) both narrated it from the hadith of Sufyan (that is, Ibn Uyayna), from Abdul-Malik bin Umayr, from Rabi bin Harash, from Huzaifa bin Yaman, who mentioned it. The wording is Ahmad's. Its chain of transmission is sahih. Tirmidhi said, "This is a hasan sahih hadith."