Language:
كتاب النكاح
67
Wedlock, Marriage (Nikaah)
(8)
Chapter: What is disliked of not marrying and of getting castrated
(8)
باب مَا يُكْرَهُ مِنَ التَّبَتُّلِ وَالْخِصَاءِ

Narrated Abu Huraira:

I said, "O Allah's Messenger (ﷺ)! I am a young man and I am afraid that I may commit illegal sexual intercourse and I cannot afford to marry." He kept silent, and then repeated my question once again, but he kept silent. I said the same (for the third time) and he remained silent. Then repeated my question (for the fourth time), and only then the Prophet said, "O Abu Huraira! The pen has dried after writing what you are going to confront. So (it does not matter whether you) get yourself castrated or not."

وَقَالَ أَصْبَغُ أَخْبَرَنِي ابْنُ وَهْبٍ، عَنْ يُونُسَ بْنِ يَزِيدَ، عَنِ ابْنِ شِهَابٍ، عَنْ أَبِي سَلَمَةَ، عَنْ أَبِي هُرَيْرَةَ ـ رضى الله عنه ـ قَالَ قُلْتُ يَا رَسُولَ اللَّهِ إِنِّي رَجُلٌ شَابٌّ وَأَنَا أَخَافُ عَلَى نَفْسِي الْعَنَتَ وَلاَ أَجِدُ مَا أَتَزَوَّجُ بِهِ النِّسَاءَ، فَسَكَتَ عَنِّي، ثُمَّ قُلْتُ مِثْلَ ذَلِكَ، فَسَكَتَ عَنِّي ثُمَّ قُلْتُ مِثْلَ ذَلِكَ، فَسَكَتَ عَنِّي ثُمَّ قُلْتُ مِثْلَ ذَلِكَ، فَقَالَ النَّبِيُّ صلى الله عليه وسلم ‏ "‏ يَا أَبَا هُرَيْرَةَ جَفَّ الْقَلَمُ بِمَا أَنْتَ لاَقٍ، فَاخْتَصِ عَلَى ذَلِكَ أَوْ ذَرْ ‏"‏‏.‏
Reference : Sahih al-Bukhari 5076
In-book reference : Book 67, Hadith 14
USC-MSA web (English) reference : Vol. 7, Book 62, Hadith 13
  (deprecated numbering scheme)