Mishkat al-Masabih 88
وَعَنْ أَبِي هُرَيْرَةَ رَضِيَ اللَّهُ عَنْهُ قَالَ قُلْتُ يَا رَسُولَ اللَّهِ إِنِّي رَجُلٌ شَابٌّ وَأَنَا أَخَافُ عَلَى نَفْسِي الْعَنَتَ وَلَا أَجِدُ مَا أَتَزَوَّجُ بِهِ النِّسَاءَ كأَنَّهُ يَسْتَأْذِنُهُ فِي الِاخْتِصَاءِ قَالَ: فَسَكَتَ عَنِّي ثُمَّ قُلْتُ مِثْلَ ذَلِكَ فَسَكَتَ عَنِّي ثُمَّ قُلْتُ مِثْلَ ذَلِكَ فَسَكَتَ عَنِّي ثُمَّ قُلْتُ مِثْلَ ذَلِكَ فَقَالَ النَّبِيُّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: «يَا أَبَا هُرَيْرَةَ جَفَّ الْقَلَمُ بِمَا أَنْتَ لَاقٍ فَاخْتَصِ على ذَلِك أَو ذَر» . رَوَاهُ البُخَارِيّ
From Abu Hurayrah, may Allah be pleased with him, who said: I said: "O Messenger of Allah, I am a young man and I fear for myself falling into sin, and I do not find the means to marry women" as though he were asking his permission to castrate himself. He said: He was silent towards me. Then I said the same, and he was silent towards me. Then I said the same, and he was silent towards me. Then I said the same, and the Prophet ﷺ said: "O Abu Hurayrah, the pen has dried with what you will meet, so castrate yourself on that basis or leave it." Reported by al-Bukhari.