Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
bukhari:5076Aṣbagh > Ibn Wahb > Yūnus b. Yazīd > Ibn Shihāb > Abū Salamah > Abū Hurayrah

I said, "O Messenger of Allah ﷺ! 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."  

البخاري:٥٠٧٦وَقَالَ أَصْبَغُ أَخْبَرَنِي ابْنُ وَهْبٍ عَنْ يُونُسَ بْنِ يَزِيدَ عَنِ ابْنِ شِهَابٍ عَنْ أَبِي سَلَمَةَ عَنْ أَبِي هُرَيْرَةَ ؓ قَالَ

قُلْتُ يَا رَسُولَ اللَّهِ إِنِّي رَجُلٌ شَابٌّ وَأَنَا أَخَافُ عَلَى نَفْسِي الْعَنَتَ وَلاَ أَجِدُ مَا أَتَزَوَّجُ بِهِ النِّسَاءَ فَسَكَتَ عَنِّي ثُمَّ قُلْتُ مِثْلَ ذَلِكَ فَسَكَتَ عَنِّي ثُمَّ قُلْتُ مِثْلَ ذَلِكَ فَسَكَتَ عَنِّي ثُمَّ قُلْتُ مِثْلَ ذَلِكَ فَقَالَ النَّبِيُّ ﷺ يَا أَبَا هُرَيْرَةَ جَفَّ الْقَلَمُ بِمَا أَنْتَ لاَقٍ فَاخْتَصِ عَلَى ذَلِكَ أَوْ ذَرْ  


See similar narrations below:

Collected by Bayhaqī
bayhaqi:13465Abū ʿAmr al-Bisṭāmī > Abū Bakr al-Ismāʿīlī > al-Ḥasan b. Sufyān > Ḥarmalah > Ibn Wahb > Yūnus > Ibn Shihāb > Abū Salamah b. ʿAbd al-Raḥman > Abū Hurayrah > Atayt Rasūl Allāh

[Machine] I came to the Messenger of Allah ﷺ and said, "O Messenger of Allah, I am a young man and I fear falling into sin, and I cannot find a woman to marry. Give me permission to restrain myself." He remained silent. Then I repeated the same statement to him, and he remained silent. Then I repeated the same statement to him, and he said, "O Abu Huraira, the pen has dried up with what you are insisting on. Either restrain yourself or marry."  

البيهقي:١٣٤٦٥أَخْبَرَنَا أَبُو عَمْرٍو الْبِسْطَامِيُّ ثنا أَبُو بَكْرٍ الْإِسْمَاعِيلِيُّ أنبأ الْحَسَنُ بْنُ سُفْيَانَ ثنا حَرْمَلَةُ أنبأ ابْنُ وَهْبٍ أَخْبَرَنِي يُونُسُ عَنِ ابْنِ شِهَابٍ عَنْ أَبِي سَلَمَةَ بْنِ عَبْدِ الرَّحْمَنِ عَنْ أَبِي هُرَيْرَةَ ؓ قَالَ

أَتَيْتُ رَسُولَ اللهِ ﷺ فَقُلْتُ يَا رَسُولَ اللهِ إِنِّي رَجُلٌ شَابٌّ وَإِنِّي أَخَافُ عَلَى نَفْسِي الْعَنَتَ وَلَا أَجِدُ مَا أَتَزَوَّجُ النِّسَاءَ فَأْذَنْ لِي أَنْ أَخْتَصِيَ قَالَ فَسَكَتَ عَنِّي ثُمَّ قُلْتُ لَهُ مِثْلَ ذَلِكَ فَسَكَتَ عَنِّي ثُمَّ قُلْتُ لَهُ مِثْلَ ذَلِكَ فَقَالَ رَسُولُ اللهِ ﷺ يَا أَبَا هُرَيْرَةَ قَدْ جَفَّ الْقَلَمُ بِمَا أَنْتَ لَاقٍ فَاخْتَصِ عَلَى ذَلِكَ أَوْ دَعْ  

أَخْرَجَهُ الْبُخَارِيُّ فِي الصَّحِيحِ فَقَالَ وَقَالَ أَصْبَغُ أَخْبَرَنِي ابْنُ وَهْبٍ فَذَكَرَهُ وَاللهُ أَعْلَمُ