كتاب المقدمات
1
The Book of Miscellany
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].

Another narration is: Messenger of Allah (ﷺ) said, "Safeguard the Commandments of Allah, you will find Him before you. Remember Him in prosperity and He will remember you in adversity. Be sure that which you miss, was not to hit you; and what hits you, was never to miss you. Remember that the Help of Allah is obtained with patience, and relief emerges after distress, prosperity follows adversity, and hardship is followed by ease".

الثالث‏:‏ عن ابن عباس، رضي الله عنهما، قال‏:‏ ‏"‏ كنت خلف النبي، صلى الله عليه وسلم، يوماً فقال‏:‏ ‏"‏ يا غلام إني أعلمك كلمات‏:‏ ‏"‏احفظ الله يحفظك، احفظ الله تجده تجاهك، إذا سألت فاسأل الله ، وإذا استعنت فاستعن بالله، واعلم‏:‏ أن الأمة لو اجتمعت على أن ينفعوك بشيء، لم ينفعوك إلا بشيء قد كتبه الله لك، وإن اجتمعوا على أن يضروك بشيء، لم يضروك بشيء إلا بشيء قد كتبه الله عليك؛ رفعت الأقلام، وجفت الصحف‏"‏ ‏(‏‏(‏رواه الترمذي وقال حديث حسن صحيح‏)‏‏)‏ ‏.‏
Arabic/English book reference : Book 1, Hadith 62