كتاب الحج
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 1330

Ibn Juraij reported:

I said to 'Ata': Have you heard Ibn 'Abbas saying: You have been commanded to observe circumambulation, and not commanded to enter it (the Ka'ba)? He ('Ata') said: He (Ibn Abbas) (at the same time) did not forbid entrance into it. I, however, heard him saying: Usama b. Zaid informed me that when Allah's Apostle (ﷺ) entered the House, he supplicated in all sides of it; and he did not observe prayer therein till he came out, and as he came out he observed two rak'ahs in front of the House, and said: This is your Qibla. I said to him: What is meant by its sides? Does that mean its corners? He said: (In all sides and nooks of the House) there is Qibla.
حَدَّثَنَا إِسْحَاقُ بْنُ إِبْرَاهِيمَ، وَعَبْدُ بْنُ حُمَيْدٍ، جَمِيعًا عَنِ ابْنِ بَكْرٍ، قَالَ عَبْدٌ أَخْبَرَنَا مُحَمَّدُ بْنُ بَكْرٍ، أَخْبَرَنَا ابْنُ جُرَيْجٍ، قَالَ قُلْتُ لِعَطَاءٍ أَسَمِعْتَ ابْنَ عَبَّاسٍ يَقُولُ إِنَّمَا أُمِرْتُمْ بِالطَّوَافِ وَلَمْ تُؤْمَرُوا بِدُخُولِهِ ‏.‏ قَالَ لَمْ يَكُنْ يَنْهَى عَنْ دُخُولِهِ وَلَكِنِّي سَمِعْتُهُ يَقُولُ أَخْبَرَنِي أُسَامَةُ بْنُ زَيْدٍ أَنَّ النَّبِيَّ صلى الله عليه وسلم لَمَّا دَخَلَ الْبَيْتَ دَعَا فِي نَوَاحِيهِ كُلِّهَا وَلَمْ يُصَلِّ فِيهِ حَتَّى خَرَجَ فَلَمَّا خَرَجَ رَكَعَ فِي قُبُلِ الْبَيْتِ رَكْعَتَيْنِ ‏.‏ وَقَالَ ‏ "‏ هَذِهِ الْقِبْلَةُ ‏"‏ ‏.‏ قُلْتُ لَهُ مَا نَوَاحِيهَا أَفِي زَوَايَاهَا قَالَ بَلْ فِي كُلِّ قِبْلَةٍ مِنَ الْبَيْتِ ‏.‏
Reference : Sahih Muslim 1330
In-book reference : Book 15, Hadith 441
USC-MSA web (English) reference : Book 7, Hadith 3075
  (deprecated numbering scheme)