Ubayy bin Kaab reported,

I heard the Prophet of Allah ﷺ say, "While Musa عليه السلام was among his people, reminding them of the days of Allah, and the days of Allah are His blessings and His trials, he said, 'I do not know any man on earth better than me or more knowledgeable than me.'Then Allah تبارك وتعالى revealed to him, 'I know better who possesses goodness, or with whom it lies. There is a man on earth who is more knowledgeable than you.'Musa said, 'My Lord, guide me to him.'He was told to take a salted fish as provision, and he did. Then he set out and met al-Khidr, and what happened between them happened.The last of it was that they passed by a village whose people were wretched. They wandered through its gathering places asking for food, but the people refused to host them."Then he related to him the story, the story of the ship, that he had only made a hole in it so that the king would pass it over and not want it. As for the boy, he had been stamped a disbeliever on the day he was stamped. His parents were devoted to him, and had he reached maturity he would have driven them to tyranny and disbelief. As for the wall, it belonged to two orphan boys in the city.

Ahmad 21120

Sahih

قال حدثني محمد بن يعقوب أبو الهيثم الزبالي قال حدثنا معتمر بن سليمان قال سمعت أبي حدثنا رقبة عن أبي إسحاق عن سعيد بن جبير عن ابن عباس حدثنا

أبي بن كعب قال

سمعت نبي الله ﷺ يقول بينما موسى عليه السلام في قومه يذكرهم بأيام الله وأيام الله نعمه وبلاؤه إذ قال ما أعلم في الأرض رجلا خيرا مني أو أعلم مني قال فأوحى الله تبارك وتعالى إليه إني أعلم بالخير من هو أو عند من هو إن في الأرض رجلا هو أعلم منك قال يا رب فدلني عليه فقيل له تزود حوتا مالحا ففعل ثم خرج فلقي الخضر فكان من أمرهما ما كان حتى كان آخر ذلك مروا بالقرية اللئام أهلها فطافا في المجالس فاستطعما فأبوا أن يضيفوهما ثم قص عليه النبأ نبأ السفينة وإنه إنما خرقها ليتجوزها الملك فلا يريدها وأما الغلام فطبع يوم طبع كافرا كان أبواه عطفا عليه فلو أنه أدرك لأرهقهما طغيانا وكفرا وأما الجدار فكان لغلامين يتيمين في المدينة

أحمد 21120صحيح
Contents
Reference
Commentary
Ayat
Collection
Musnad Ahmad
Book
Abdullah bin Abbas from Ubayy bin Kaab
Numbering
Darussalam 21120
Ahmad 21120