We were with the Messenger of Allah ﷺ as young men with nothing to our name, when he said, "Young men, whoever among you can afford marriage should marry, for it lowers the gaze and guards the private parts. Whoever cannot should fast, for fasting is a shield for him."
حدثنا يعلى بن عبيد حدثنا الأعمش عن عمارة عن عبد الرحمن بن يزيد قال
كنا مع رسول الله ﷺ شبابا ليس لنا شيء فقال يا معشر الشباب من استطاع منكم الباءة فليتزوج فإنه أغض للبصر وأحصن للفرج ومن لم يستطع فعليه بالصوم فإن الصوم له وجاء
Its chain of transmission is sahih. Umarah is Ibn Umayr Taymi, whose reliability was established earlier at 342. Ahmad said, "He is trustworthy, and more than that, is he even to be asked about?"The hadith is an abridgment of 3592, see also 4035.