Abdullah bin Masud reported,

We used to go on military expeditions with the Messenger of Allah ﷺ and we had nothing with us. We said, "Should we not castrate ourselves?" But he forbade us from doing so. Then he permitted us to marry a woman in exchange for a garment as her dowry, and he recited to us, "O you who believe, do not forbid the good things that Allah has made lawful for you, and do not transgress. Indeed, Allah does not love the transgressors" [Maidah 5:87].

Azami 6181

Sahih

عن عبد الله بن مسعود قال

كنا نغزو مع رسول الله ﷺ وليس لنا شيء، فقلنا: ألا نستخصي؟ فنهانا عن ذلك، ثم رخص لنا أن ننكح المرأة بالثوب، ثم قرأ علينا {يأيها الذين ءامنوا لا تحرموا طيبات ما أحل الله لكم ولا تعتدوا إن الله لا يحب المعتدين} [المائدة: ٨٧].

الأعظمي 6181صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Marriage
Chapter
Marriage and its conditions
Section
Encouragement of youth to marry and the dislike of celibacy and castration
Numbering
Jami al-Kamil 6181 (2nd edition)