Sayyiduna Sa'd bin Abi Waqqas (may Allah be pleased with him) says that Sayyiduna Uthman bin Maz'un (may Allah be pleased with him) intended to withdraw (from women into celibacy), so the Prophet (peace and blessings be upon him) forbade him. Had he (peace and blessings be upon him) permitted it, we would have castrated ourselves.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب النكاح / 13462
Qays says: I heard Abdullah (may Allah be pleased with him) say: We used to go on military expeditions and we had no women with us. We said: "Should we not castrate ourselves?" So he (peace and blessings be upon him) forbade us from that. Then we were given permission to marry women for a garment. Then he recited this verse: "O you who believe, do not make unlawful the good things that Allah has made lawful for you, and do not transgress. Indeed, Allah does not love the transgressors." [Surah Al-Ma'idah: 87]
Hadith Referenceالسنن الكبرى للبيهقي / كتاب النكاح / 13464
Sayyiduna Abu Hurayrah (may Allah be pleased with him) says: I came to the Prophet (peace and blessings be upon him) and said: "O Messenger of Allah (peace and blessings be upon him)! I am a young man, I fear falling into sin, and I do not find (the means) to marry a woman. Will you permit me to castrate myself?" He (peace and blessings be upon him) remained silent for a while. Then I repeated the same thing, and he (peace and blessings be upon him) again remained silent. Then I said it (a third time), and he (peace and blessings be upon him) said: "O Abu Hurayrah! The pen has dried concerning what you will meet; what is to happen will happen, whether you castrate yourself or not." [Sahih. Bukhari 5076]
Hadith Referenceالسنن الكبرى للبيهقي / كتاب النكاح / 13465