Sayyiduna Sahl bin Sa'd al-Sa'idi (may Allah be pleased with him) narrates that a man peeped through a hole in the door of the Messenger of Allah (peace and blessings be upon him), while the Messenger of Allah (peace and blessings be upon him) had a comb with which he (peace and blessings be upon him) was combing his hair. So the Messenger of Allah (peace and blessings be upon him) said to him: "Had I known that you were looking at me, I would have thrust this into your eye. Seeking permission has only been prescribed because of the gaze."
Hadith Referenceالمعجم الكبير للطبراني / باب السين / 5652