Traced to Ka'b al-Ahbar (automatic guess): a report of earlier scriptures, not a hadith of the Prophet ﷺ.
إني سائلكم عن شيء، وإياكم أن تكذبوني فتهلكوني وتهلكوا أنفسكم، أنشدكم بالله ماذا تجدوني في كتبكم، أخليفة أنا أم ملك؟ فقال طلحة والزبير: إنك لتسألنا عن أمر ما نعرفه، ما ندري ما الخليفة، ولست بملك، فقال عمر: إن يقل فقد كنت تدخل فتجلس مع رسول الله صلى الله عليه وسلم، ثم قال سلمان: وذلك أنك تعدل في الرعية، وتقسم بينهم بالسوية، وتشفق عليهم شفقة الرجل على أهله، وقال محمد بن يزيد: وتقضي بكتاب الله، فقال كعب: ما كنت أحسب أن في المجلس أحدا يعرف الخليفة من الملك غيري، ولكن الله ملأ سلمان حكما وعلما، ثم قال كعب: أشهد أنك خليفة ولست بملك، فقال له عمر: وكيف ذاك؟ قال: أجدك في كتاب الله ، قال عمر: تجدني باسمي؟ قال كعب: لا، ولكن بنعتك، أجد نبوة، ثم خلافة ورحمة، وقال محمد بن يزيد: خلافة على منهاج نبوة، ثم ملكا عضوضا قال: وقال هشيم: وجبرية وملكا عضوضا، فقال عمر: ما أبالي إذا جاوز ذلك رأسي
I am asking you about something, and be careful not to deny me, lest you destroy me and destroy yourselves. I adjure you by Allah: What do you find me in your books, am I a caliph or a king? Talha and Al-Zubayr said: You are asking us about a matter that we do not know. We do not know what a caliph is, and I am not a king. Umar said: If he says so, you used to enter and sit with the Messenger of Allah (may Allah’s prayers and peace be upon him). Then Salman said: That is because you are fair to the subjects, dividing equally among them, and you have compassion for them as a man has compassion for his family. Muhammad bin Yazid said: And you judge according to the Book of Allah. Ka’b said: I did not think that there was anyone in the council who knew the caliph from the king except me, but Allah. Salman was full of wisdom and knowledge, then Kaab said: I bear witness that you are a caliph and not a king, so Omar said to him: How is that? He said: I find you in the Book of Allah. Omar said: You find me in my name? Ka'b said: No, but with your blessing, I find prophethood, then a caliphate and mercy. Muhammad bin Yazid said: A caliphate on the method of prophecy, then a strong kingship. He said: Hushaym said: Jabriyah and a strong kingship. Omar said: I don't care if that goes beyond my head.
محمد بن يزيدالعوام بن حوشبautomatic reading, unverified