كتاب الحج
15  
The Book of Pilgrimage
(68)
Chapter: It is recommended for pilgrims and others to enter the Ka'bah and pray therein, and supplicate in all its corners
(68)
باب اسْتِحْبَابِ دُخُولِ الْكَعْبَةِ لِلْحَاجِّ وَغَيْرِهِ وَالصَّلاَةِ فِيهَا وَالدُّعَاءِ فِي نَوَاحِيهَا كُلِّهَا
Sahih Muslim 1329 e

Abdullah b. Umar reported that he reached the Ka'ba and Allah's Apostle (ﷺ) had entered therein, and Bilal and Usama too. 'Uthman b. Talha closed the door to them, and they stayed there for a considerable time, and then the door was opend and Allah's Apostle (ﷺ) came out, and I went upstairs and entered the House and said:

Where did Allah's Apostle (ﷺ) observe prayer? They said: At this very place. I, however, forgot to ask them about the (number of) rak'ahs that he observed.
وَحَدَّثَنِي حُمَيْدُ بْنُ مَسْعَدَةَ، حَدَّثَنَا خَالِدٌ، - يَعْنِي ابْنَ الْحَارِثِ - حَدَّثَنَا عَبْدُ اللَّهِ، بْنُ عَوْنٍ عَنْ نَافِعٍ، عَنْ عَبْدِ اللَّهِ بْنِ عُمَرَ، أَنَّهُ انْتَهَى إِلَى الْكَعْبَةِ وَقَدْ دَخَلَهَا النَّبِيُّ صلى الله عليه وسلم وَبِلاَلٌ وَأُسَامَةُ وَأَجَافَ عَلَيْهِمْ عُثْمَانُ بْنُ طَلْحَةَ الْبَابَ قَالَ فَمَكَثُوا فِيهِ مَلِيًّا ثُمَّ فُتِحَ الْبَابُ فَخَرَجَ النَّبِيُّ صلى الله عليه وسلم وَرَقِيتُ الدَّرَجَةَ فَدَخَلْتُ الْبَيْتَ فَقُلْتُ أَيْنَ صَلَّى النَّبِيُّ صلى الله عليه وسلم قَالُوا هَا هُنَا ‏.‏ قَالَ وَنَسِيتُ أَنْ أَسْأَلَهُمْ كَمْ صَلَّى.
Reference : Sahih Muslim 1329e
In-book reference : Book 15, Hadith 438
USC-MSA web (English) reference : Book 7, Hadith 3072
  (deprecated numbering scheme)