I was walking with Abdullah bin Masud at Mina when Uthman met him and took him aside for a private conversation. When Abdullah saw that Uthman had no particular need from him, he said to me, "Come over, Alqama." So I came.Uthman said to him, "Abu Abdul-Rahman, shall we marry you to a young virgin girl? Perhaps she will restore to you something of the vigor you used to have."Abdullah replied, "If you say that, I have indeed heard the Messenger of Allah ﷺ say, 'Whoever among you is able to marry, let him marry, for it lowers the gaze and guards the private parts. And whoever is unable, let him fast, for it will be a shield for him.'"
حدثنا عثمان بن أبي شيبة حدثنا جرير عن الأعمش عن إبراهيم
إني لأمشي مع عبد الله بن مسعود بمنى إذ لقيه عثمان فاستخلاه فلما رأى عبد الله أن ليست له حاجة قال لي تعال يا علقمة فجئت فقال له عثمان ألا نزوجك يا أبا عبد الرحمن بجارية بكر لعله يرجع إليك من نفسك ما كنت تعهد فقال عبد الله لئن قلت ذاك لقد سمعت رسول الله ﷺ يقول من استطاع منكم الباءة فليتزوج فإنه أغض للبصر وأحصن للفرج ومن لم يستطع منكم فعليه بالصوم فإنه له وجاء
Sourced from Bukhari, Fasting, chapter on fasting for one who fears celibacy for himself, hadith no. 1905 etc., hadith no. 1400, and Muslim, Marriage, chapter on the recommendation of marriage for one whose soul longs for it and who can afford its expenses, the hadith of Amash, with the same wording.