Bulugh al-Maram 1487
وَعَنْ سَهْلِ بْنِ سَعْدٍ قَالَ: جَاءَ رَجُلٌ إِلَى النَّبِيِّ - صلى الله عليه وسلم - فَقَالَ: يَا رَسُولَ اللَّهِ! دُلَّنِي عَلَى عَمَلٍ إِذَا عَمِلْتُهُ أَحَبَّنِي اللَّهُ, وَأَحَبَّنِي النَّاسُ. فـ قَالَ: «ازْهَدْ فِي الدُّنْيَا يُحِبُّكَ اللَّهُ, وَازْهَدْ فِيمَا عِنْدَ النَّاسِ يُحِبُّكَ النَّاسُ». رَوَاهُ ابْنُ مَاجَه, وَسَنَدُهُ حَسَنٌ.
From Sahl ibn Saʿd, who said: A man came to the Prophet ﷺ and said: "O Messenger of Allah, guide me to a deed which, if I do it, Allah will love me and people will love me." He said: "Renounce the world and Allah will love you, and renounce what people have and people will love you." Ibn Majah reported it, and its chain is hasan.