Sayyiduna Abu Mas'ud (may Allah be pleased with him) said: A man asked the Prophet (peace and blessings be upon him): O Messenger of Allah (peace and blessings be upon him)! How can I know whether I have done well or badly? He (peace and blessings be upon him) said: "Listen to your neighbour: if he says that you have done well, then it is good; and when you hear them saying: You have done badly, then you have indeed done badly."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب آداب القاضي / 20396
Kulthum al-Khuza'i (may Allah be pleased with him) said: A man came to the Prophet (peace and blessings be upon him) and said: O Messenger of Allah! If I do good or bad, how can I recognise it? He (peace and blessings be upon him) said: "When your neighbours say that you have done good or bad, then you truly have done good or bad."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب آداب القاضي / 20397
Sayyiduna Ibn Umar (may Allah be pleased with them both) said: I was with the Messenger of Allah (peace and blessings be upon him). A man passed by the Prophet (peace and blessings be upon him), asking him for something. He (peace and blessings be upon him) said: "O Ibn Umar, do you know him?" I said: Yes. He (peace and blessings be upon him) asked: "What is his name?" I said: I do not know. He (peace and blessings be upon him) asked: "Where is his house?" I said: I do not know. He (peace and blessings be upon him) said: "This is not knowing him."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب آداب القاضي / 20398
Ibn Abi Najih (may Allah have mercy on him) said: A man passed by the Prophet (peace and blessings be upon him), and he (peace and blessings be upon him) asked: "Who knows him?" A man said: I know him by his face, but I do not know his name. He (peace and blessings be upon him) said: "That is not knowing him."
This mursal version is the correct one.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب آداب القاضي / 20399
Kharashah bin al-Hurr (may Allah have mercy on him) said: A man came to Sayyiduna Umar bin al-Khattab (may Allah be pleased with him) to give testimony. He (may Allah be pleased with him) said to him: I do not know you, but that will not harm you at all once you bring someone who knows you. A man from the people said: I know him. He (may Allah be pleased with him) asked: By what do you know him? He said: By his uprightness and virtue. He (may Allah be pleased with him) said: Is he your near neighbour, so that you know his nights and days and are familiar with his comings and goings? He said: No. He (may Allah be pleased with him) said: Have you inferred his piety through dealings in dirhams and dinars? He said: No. He (may Allah be pleased with him) asked: Was he your companion on a journey, so that you infer his good character? He said: No. Sayyiduna Umar (may Allah be pleased with him) said: You do not know him. Bring someone who knows you.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب آداب القاضي / 20400