Sayyiduna Mu'awiyah bin Haydah (may Allah be pleased with him) narrated: I said: "O Messenger of Allah! Our private parts: what may we expose of them and what must we cover?" He (peace and blessings be upon him) said: "Guard your private parts except from your wife and your slave woman." I said: "O Messenger of Allah! And when some people are gathered together with one another?" He (peace and blessings be upon him) said: "If you are able to ensure that no one sees your private parts, then do so." The people said: "What if one of us is alone?" He (peace and blessings be upon him) said: "Allah is more deserving that one should feel modesty before Him." And he (peace and blessings be upon him) placed his hand over his private part.
Hadith Referenceالمعجم الكبير للطبراني / باب الميم / 17038