He informed him that a man peeked through a hole in the door of the Messenger of Allah ﷺ, while the Messenger of Allah ﷺ had a comb with which he was scratching his head. When the Messenger of Allah ﷺ saw him, he said, "Had I known you were watching me, I would have jabbed it into your eyes."The Messenger of Allah ﷺ said, "Permission to enter was prescribed only because of sight."
أخبره أن رجلا اطلع في جحر في باب رسول الله ﷺ ومع رسول الله ﷺ مدرى يحك به رأسه- فلما رآه رسول الله ﷺ قال: لو أعلم أنك تنتظرني لطعنت به في عينيك وقال رسول الله ﷺ: إنما جعل الإذن من قبل البصر.
Bukhari narrated it in the Book of Blood Money (6901) and Muslim in the Book of Manners (2156), both through Qutayba bin Saeed, who said, "Muhaddith Layth (he is Ibn Saad) told us, from Ibn Shihab, that Sahl bin Saad Saadi informed him," and he related it.His saying, "a hole," means the opening. And his saying, "permission was only established," means that seeking permission is a legislated command. It was established only so that the eye would not fall upon what is forbidden, and so it is not permissible for anyone to look through the opening of a door or anything similar.This hadith shows that it is permissible to throw something light at the eye of one who peeps in, so that if he threw it and it put out the eye, there would be no liability upon him.