Abdullah bin Abbas reported,

Ibn Abbas and Hurr bin Qays bin Hisn al-Fazari disagreed about the companion of Musa. Ibn Abbas said, "He was Khadir."Then Ubayy bin Kaab passed by them, and Ibn Abbas called him over and said, "My companion and I have disagreed about the companion of Musa, the one whom Musa asked about the way to meet him. Did you hear the Prophet ﷺ mention his story?"Ubayy replied, "Yes, I heard the Messenger of Allah ﷺ say, 'While Musa was among a gathering of the Children of Israil, a man came to him and asked, "Do you know anyone more knowledgeable than yourself?" Musa answered, "No." So Allah عز وجل revealed to Musa, "Yes, Our servant Khadir is." Musa then asked about the way to reach him, and Allah made the fish a sign for him, telling him, "When you lose the fish, turn back, for you will meet him." So Musa followed the fish's trail in the sea, and his servant said to him, "Do you remember when we took refuge at the rock? I forgot the fish, and none made me forget to mention it but Satan." [Kahf 18:63]. "He said, 'That is what we were seeking.' So they returned, retracing their footsteps." [Kahf 18:64]. Then they found Khadir, and what happened between them was as Allah عز وجل recounted in His Book.'"

Bukhari 74

Sahih

حدثني محمد بن غرير الزهري قال حدثنا يعقوب بن إبراهيم قال حدثني أبي عن صالح عن ابن شهاب حدثه أن عبيد الله بن عبد الله أخبره

عن ابن عباس

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

البخاري 74صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Knowledge
Chapter
Musa ﷺ going into the sea to Khidr
Numbering
Darussalam 74
Bukhari 74