Sahih al-Bukhari 6241
Narration text is preserved in its supplied Arabic and English. Translated interfaces and reading guides do not add narration translations in other languages.
لَوْ أَعْلَمُ أَنَّكَ تَنْظُرُ لَطَعَنْتُ بِهِ فِي عَيْنِكَ، إِنَّمَا جُعِلَ الاِسْتِئْذَانُ مِنْ أَجْلِ الْبَصَرِ "
Narrated Sahl bin Sa`d:
A man peeped through a round hole into the dwelling place of the Prophet, while the Prophet (ﷺ) had a Midray (an iron comb) with which he was scratching his head. the Prophet (ﷺ) said, " Had known you were looking (through the hole), I would have pierced your eye with it (i.e., the comb)." Verily! The order of taking permission to enter has been enjoined because of that sight, (that one should not look unlawfully at the state of others). (See Hadith No. 807, Vol. 7)
Full reference and source
Sahih al-Bukhari 6241 In-book : Book 79, Hadith 15 USC-MSA web (English) : Vol. 8, Book 74, Hadith 258 (deprecated)
View source on Sunnah.com (opens in a new tab)