Sunan an-Nasa'i, Book 22, Hadith 150 (In-Book) ⓘ
It was narrated that 'Abdullah said: "We went out with the Messenger of Allah and we were young men who could not afford anything. He said: 'O young men, you should get married, for it is more effective in lowering the gaze and protecting one's chastity. Whoever cannot afford it should fast, for it will be a restraint Wija, for him."'
أَخْبَرَنَا مَحْمُودُ بْنُ غَيْلاَنَ، قَالَ حَدَّثَنَا أَبُو أَحْمَدَ، قَالَ حَدَّثَنَا سُفْيَانُ، عَنِ الأَعْمَشِ، عَنْ عُمَارَةَ بْنِ عُمَيْرٍ، عَنْ عَبْدِ الرَّحْمَنِ بْنِ يَزِيدَ، عَنْ عَبْدِ اللَّهِ، قَالَ خَرَجْنَا مَعَ رَسُولِ اللَّهِ صلى الله عليه وسلم وَنَحْنُ شَبَابٌ لاَ نَقْدِرُ عَلَى شَىْءٍ قَالَ " يَا مَعْشَرَ الشَّبَابِ عَلَيْكُمْ بِالْبَاءَةِ فَإِنَّهُ أَغَضُّ لِلْبَصَرِ وَأَحْصَنُ لِلْفَرْجِ وَمَنْ لَمْ يَسْتَطِعْ فَعَلَيْهِ بِالصَّوْمِ فَإِنَّهُ لَهُ وِجَاءٌ " .
also referenced under: Hadith 2239 (Reference) & Volume 3, Book 22, Hadith 2241 (DarusSalam)