Sahih Muslim 1400 c
Narration text is preserved in its supplied Arabic and English. Translated interfaces and reading guides do not add narration translations in other languages.
يَا مَعْشَرَ الشَّبَابِ مَنِ اسْتَطَاعَ مِنْكُمُ الْبَاءَةَ فَلْيَتَزَوَّجْ فَإِنَّهُ أَغَضُّ لِلْبَصَرِ وَأَحْصَنُ لِلْفَرْجِ وَمَنْ لَمْ يَسْتَطِعْ فَعَلَيْهِ بِالصَّوْمِ فَإِنَّهُ لَهُ وِجَاءٌ "
Abdullah (b. Mas'ud) (Allah be pleased with him) reported that Allah's Messenger (ﷺ) said to us:
0 young men, those among you who can support a wife should marry, for it restrains eyes (from casting evil glances) and preserves one from immorality; but he who cannot afford It should observe fast for it is a means of controlling the sexual desire.
Full reference and source
Sahih Muslim 1400 c In-book : Book 16, Hadith 3 USC-MSA web (English) : Book 8, Hadith 3233 (deprecated)
View source on Sunnah.com (opens in a new tab)