Abu Hurairah reported,

I came to the Messenger of Allah ﷺ and said, "Messenger of Allah, I am a young man, and I fear hardship upon myself, yet I cannot find the means to marry. Will you permit me to castrate myself?"He remained silent. I repeated the same request three times.Then the Messenger of Allah ﷺ said, "Abu Hurayrah, the pen has already dried regarding what you will encounter, so castrate yourself on that basis or leave it."

Azami 1097

Sahih

عن أبي هريرة، قال

أتيت رسول الله ﷺ فقلت: يا رسول الله، إني رجل شاب، وإني أخاف على نفسي العنت، ولا أجد ما أتزوج به النساء، فاذن لي أن أختصي؟ قال: فسكت عني، ثم قلت مثل ذلك ثلاث مرات. فقال رسول الله ﷺ: يا أبا هريرة قد جف القلم بما أنت لاق، فاختص على ذلك أو ذر.

الأعظمي 1097صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Faith
Chapter
Belief in the divine decree and predestination
Section
Pen has dried with what you will encounter
Numbering
Jami al-Kamil 1097 (2nd edition)
Azami 1097