I asked, "Messenger of Allah, regarding our private parts, which may we expose and which must we cover?"He replied, "Guard your private parts from everyone except your wife or those your right hand possesses."The man asked, "What if a man is with another man?"He said, "If you can manage that no one sees it, then do so."I asked, "And what if a man is alone?"He replied, "Allah is more deserving that one feel shame before Him."
حدثنا محمد بن بشار حدثنا يحيى بن سعيد
قلت يا رسول الله عوراتنا ما نأتي منها وما نذر قال احفظ عورتك إلا من زوجتك أو ما ملكت يمينك فقال الرجل يكون مع الرجل قال إن استطعت أن لا يراها أحد فافعل قلت والرجل يكون خاليا قال فالله أحق أن يستحيا منه
[Its isnad is hasan]. Abu Dawud also narrated it in the chapter on the bathhouse, section on undressing, hadith no. 4017, from Muhammad bin Bashshar with the same wording. Bukhari mentioned it as a suspended narration in his Sahih, before hadith no. 278. Hakim graded it sahih in al-Mustadrak, 4/179–180, and Dhahabi agreed with him.