He once rode behind the Messenger of Allah ﷺ, and the Messenger of Allah ﷺ said to him, "Young man, I will teach you a few words. Be mindful of Allah, and He will protect you. Be mindful of Allah, and you will find Him before you. When you ask, ask Allah. When you seek help, seek it from Allah. Know that if the entire nation were to gather to benefit you with something, they could not benefit you except with what Allah has already decreed for you, and if they were to gather to harm you with something, they could not harm you except with what Allah has already decreed against you. The pens have been lifted and the pages have dried."
حدثنا يونس حدثنا ليث عن قيس بن الحجاج عن حنش الصنعاني
أنه ركب خلف رسول الله ﷺ يوما فقال له رسول الله ﷺ يا غلام إني معلمك كلمات احفظ الله يحفظك احفظ الله تجده تجاهك وإذا سألت فلتسأل الله وإذا استعنت فاستعن بالله واعلم أن الأمة لو اجتمعوا على أن ينفعوك لم ينفعوك إلا بشيء قد كتبه الله لك ولو اجتمعوا على أن يضروك لم يضروك إلا بشيء قد كتبه الله عليك رفعت الأقلام وجفت الصحف
Its isnad is sahih. Layth is Ibn Saad, and Qays bin Hajjaj Kalai is trustworthy. Ibn Hibban mentioned him in Thiqat, and Ibn Yunus said he was a righteous man. Bukhari gave his biography in Kabir 4/1/155. He has no hadith in the Six Books other than this one, narrated by Tirmidhi, and it is hadith 19 of Arbaeen Nawawiyyah.Nawawi said, Tirmidhi narrated it and said, a hasan sahih hadith.Hafiz bin Rajab said in Jami al-Ulum wal-Hikam 132, Imam Ahmad narrated it through the hadith of Hanash Sanani along with two other disconnected isnads, without distinguishing one from the other. It seems that Hafiz bin Rajab saw in the Musnad only the isnad he referred to, which will come at 2804. But Imam Ahmad actually narrated it twice with two sahih isnads through Hanash, each with distinct wording not mixed together with a disconnected isnad, and these are this hadith and hadith 2763.