It is narrated from Sayyiduna Anas bin Malik (may Allah be pleased with him) that he said: "The Messenger of Allah (peace and blessings be upon him) came out to us, and in those days we were all young men, and the Prophet (peace and blessings be upon him) said: 'You must marry, and whoever is not able to, let him fast, for it is a shield (curbing desire) for him.'"
Sulayman bin al-Mughirah narrated it through Thabit from Sayyiduna Anas (may Allah be pleased with him).
And it has already passed in his section.
Related hadith on this topic