I asked, "Messenger of Allah, regarding our private parts, which of them 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."I asked, "Messenger of Allah, what if people are mingled together?"He said, "If you can manage that no one sees them, then let no one see them."I asked, "Messenger of Allah, what if one of us is alone?"He answered, "Allah is more deserving of modesty than people."
حدثنا عبد الله بن مسلمة حدثنا أبي ح و حدثنا ابن بشار حدثنا يحيى نحوه
قلت يا رسول الله عوراتنا ما نأتي منها وما نذر قال احفظ عورتك إلا من زوجتك أو ما ملكت يمينك قال قلت يا رسول الله إذا كان القوم بعضهم في بعض قال إن استطعت أن لا يرينها أحد فلا يرينها قال قلت يا رسول الله إذا كان أحدنا خاليا قال الله أحق أن يستحيا منه من الناس
[Its isnad is hasan] Tirmidhi narrated it in "Etiquette," chapter on what has been said about covering one's private parts, hadith 2794, from the hadith of Bahz bin Hakeem through him, and he said, hasan. Bukhari mentioned it without a full chain before hadith 278, and Ibn Majah also narrated it, hadith 1920.