The Prophet ﷺ said, "A man must not look at the private parts of another man, nor a woman at the private parts of another woman. A man must not lie with another man under one garment, nor a woman with another woman under one garment."
حدثنا محمد بن إسماعيل بن أبي فديك حدثنا الضحاك يعني ابن عثمان عن زيد بن أسلم
أن النبي ﷺ قال لا ينظر الرجل إلى عورة الرجل ولا تنظر المرأة إلى عورة المرأة ولا يفض الرجل إلى الرجل في الثوب ولا تفض المرأة إلى المرأة في الثوب
Its isnad is sahih. Dahhak bin Uthman bin Abdullah Hizami is truthful but makes mistakes, and his hadith is found in Muslim.The hadith was narrated by Muslim, 1/266, no. 338, in the Book of Menstruation, on the prohibition of looking at private parts, by Abu Dawud, 4/41, no. 4018, in the Book of Bathing, on what has been said about undressing, and by Tirmidhi, 5/109, no. 2793, in the Book of Etiquette, on the disapproval of a man having direct bodily contact, where he said, hasan gharib sahih, and by Bayhaqi, 7/98.