Language:
كتاب المناقب
61  
Virtues and Merits of the Prophet (pbuh) and his Companions
(25)
Chapter: The signs of Prophethood in Islam
(25)
باب عَلاَمَاتِ النُّبُوَّةِ فِي الإِسْلاَمِ
Sahih al-Bukhari 3594

Narrated Abu Sa`id Al-Khudri:

The Prophet (ﷺ) said, "A time will come when the people will wage holy war, and it will be asked, 'Is there any amongst you who has enjoyed the company of Allah's Messenger (ﷺ)?' They will say: 'Yes.' And then victory will be bestowed upon them. They will wage holy war again, and it will be asked: 'Is there any among you who has enjoyed the company of the companions of Allah's Messenger (ﷺ) ?' They will say: 'Yes.' And then victory will be bestowed on them."

حَدَّثَنَا قُتَيْبَةُ بْنُ سَعِيدٍ، حَدَّثَنَا سُفْيَانُ، عَنْ عَمْرٍو، عَنْ جَابِرٍ، عَنْ أَبِي سَعِيدٍ ـ رضى الله عنه ـ عَنِ النَّبِيِّ صلى الله عليه وسلم قَالَ ‏ "‏ يَأْتِي عَلَى النَّاسِ زَمَانٌ يَغْزُونَ، فَيُقَالُ فِيكُمْ مَنْ صَحِبَ الرَّسُولَ صلى الله عليه وسلم فَيَقُولُونَ نَعَمْ‏.‏ فَيُفْتَحُ عَلَيْهِمْ، ثُمَّ يَغْزُونَ فَيُقَالُ لَهُمْ هَلْ فِيكُمْ مَنْ صَحِبَ مَنْ صَحِبَ الرَّسُولَ صلى الله عليه وسلم فَيَقُولُونَ نَعَمْ‏.‏ فَيُفْتَحُ لَهُمْ ‏"‏‏.‏
Reference : Sahih al-Bukhari 3594
In-book reference : Book 61, Hadith 101
USC-MSA web (English) reference : Vol. 4, Book 56, Hadith 792
  (deprecated numbering scheme)