Sahl bin Saad reported,

A man peeped at the Messenger of Allah ﷺ through a hole in the Prophet's ﷺ room while the Prophet ﷺ held a comb with which he was scratching his head. The Prophet ﷺ said, "Had I known you were looking, I would have stabbed it into your eye. The requirement of seeking permission was established only because of sight."

Tirmidhi 2709

Sahih

حدثنا ابن أبي عمر حدثنا سفيان عن الزهري

عن سهل بن سعد الساعدي

أن رجلا اطلع على رسول الله ﷺ من جحر في حجرة النبي ﷺ ومع النبي ﷺ مدراة يحك بها رأسه فقال النبي ﷺ لو علمت أنك تنظر لطعنت بها في عينك إنما جعل الاستئذان من أجل البصر

الترمذي 2709صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami Tirmidhi
Book
Permission and etiquette
Chapter
One who peeps into the house of people without their permission
Numbering
Darussalam 2709
Tirmidhi 2709