كتاب المقدمات
The Book of Miscellany
(5)
Chapter: Watchfulness
(5)
- باب المراقبة
Riyad as-Salihin 62
Ibn Abbas (May Allah be pleased with them) said:
One day, I was riding behind the Prophet (ﷺ) when he said, "O boy! I will instruct you in some matters. Be watchful of Allah (Commandments of Allah), He will preserve you. Safeguard His Rights, He will be ever with you. If you beg, beg of Him Alone; and if you need assistance, supplicate to Allah Alone for help. And remember that if all the people gather to benefit you, they will not be able to benefit you except that which Allah had foreordained (for you); and if all of them gather to do harm to you, they will not be able to afflict you with anything other than that which Allah had pre-destined against you. The pens had been lifted and the ink had dried up".

[At- Tirmidhi, who categorized it as Hadith Hasan Sahih].
الثالث‏:‏ عن ابن عباس، رضي الله عنهما، قال‏:‏ ‏"‏ كنت خلف النبي، صلى الله عليه وسلم، يوماً فقال‏:‏ ‏"‏ يا غلام إني أعلمك كلمات‏:‏ ‏"‏احفظ الله يحفظك، احفظ الله تجده تجاهك، إذا سألت فاسأل الله ، وإذا استعنت فاستعن بالله، واعلم‏:‏ أن الأمة لو اجتمعت على أن ينفعوك بشيء، لم ينفعوك إلا بشيء قد كتبه الله لك، وإن اجتمعوا على أن يضروك بشيء، لم يضروك بشيء إلا بشيء قد كتبه الله عليك؛ رفعت الأقلام، وجفت الصحف‏"‏ ‏(‏‏(‏رواه الترمذي وقال حديث حسن صحيح‏)‏‏)‏ ‏.‏
Reference : Riyad as-Salihin 62
In-book reference : Introduction, Hadith 62