All perfect praise be to Allah, the Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
We could not find a Hadeeth with the exact wording that you have mentioned in your question. However, there are some Ahadeeth that bear a similar meaning. For example, the Prophet, sallallaahu ‘alayhi wa sallam, said, “Whoever dies while having no allegiance to a ruler will dies in a state of ignorance.” [Muslim] Another narration reads, “Whoever dies while having no ruler will die in a state of ignorance.” [Abu Ya‘la] In this context, the word “ruler” refers to the Muslim ruler who takes care of the religious and worldly interests of his subjects. In the same regard, Huthayfah asked the Prophet, sallallaahu ‘alayhi wa sallam, what to do at times of strife and turmoil. The Prophet, sallallaahu ‘alayhi wa sallam, said to him, “Adhere to the Muslim mainstream and their leader.” [Muslim]
Allah knows best.