Sahih al-Bukhari 5076
And Asbagh (bin Faraj) said: (Abdullah) Ibn Wahb informed me. He told me, narrating from Yunus bin Yazid (Aili), Yunus from Ibn Shihab, Ibn Shihab from Abu Salamah (Abdullah bin Abdur Rahman bin Auf), Abu Salamah from Hazrat Abu Hurairah (ra). He used to say: I submitted: O Messenger of Allah (saw)! I am a young man and I fear for myself that I may fall into sin, and I do not even have the means with which to marry women. On hearing what I said, he (saw) remained silent. Then I said the same. He (saw) again remained silent. Then I said the same. Even then he (saw) remained silent. Then I said the same. The Prophet (saw) said: “Abu Hurairah! The pen has dried after writing what was to reach you. With this decree in place, now have yourself castrated or not.”
AI-translated by Islam-Today
Book 8: What is disliked of not marrying and of getting castrated