The Prophet ﷺ said, with the same meaning as Musaddad's narration, "Whoever stays close to the ruler is tested with trial." He added, "A servant does not draw nearer to the ruler except that he grows further from Allah."
حدثنا محمد بن عيسى حدثنا محمد بن عبيد حدثنا الحسن بن الحكم النخعي عن عدي بن ثابت عن شيخ من الأنصار
عن النبي ﷺ بمعنى مسدد قال ومن لزم السلطان افتتن زاد وما ازداد عبد من السلطان دنوا إلا ازداد من الله بعدا
No references are available.
[Its chain of transmission is daif] Ahmad narrated it: 2/440, from Muhammad bin Ubayd, with this chain. * The shaikh from the Ansar, I could not identify him.