Jami` at-Tirmidhi, Book 42, Hadith 22 (In-Book) ⓘ
Narrated Sahl bin Sa'd As-Sa'idi: that a man peeked in on the Messenger of Allah, in one of the apartments of the Prophet, while the Prophet had a Midrah (an iron comb) with which he was scratching his head. So the Prophet said: "If I knew that you were looking then I would have poked your eyes with it. Seeking permission has only been enjoined because of the sight."
حَدَّثَنَا ابْنُ أَبِي عُمَرَ، حَدَّثَنَا سُفْيَانُ، عَنِ الزُّهْرِيِّ، عَنْ سَهْلِ بْنِ سَعْدٍ السَّاعِدِيِّ، أَنَّ رَجُلاً، اطَّلَعَ عَلَى رَسُولِ اللَّهِ صلى الله عليه وسلم مِنْ جُحْرٍ فِي حُجْرَةِ النَّبِيِّ صلى الله عليه وسلم وَمَعَ النَّبِيِّ صلى الله عليه وسلم مِدْرَاةٌ يَحُكُّ بِهَا رَأْسَهُ فَقَالَ النَّبِيُّ صلى الله عليه وسلم " لَوْ عَلِمْتُ أَنَّكَ تَنْظُرُ لَطَعَنْتُ بِهَا فِي عَيْنِكَ إِنَّمَا جُعِلَ الاِسْتِئْذَانُ مِنْ أَجْلِ الْبَصَرِ " . وَفِي الْبَابِ عَنْ أَبِي هُرَيْرَةَ . قَالَ أَبُو عِيسَى هَذَا حَدِيثٌ حَسَنٌ صَحِيحٌ .
also referenced under: Hadith 2709 (Reference) & Volume 5, Book 40, Hadith 2709 (DarusSalam)