كتاب الفتن وأشراط الساعة
54  
The Book of Tribulations and Portents of the Last Hour
(18)
Chapter: The Hour Will Not Begin Until A Man Passes By Another Man's Grave And Wishes That He Was In The Place Of The Deceased, Because Of Calamity
(18)
بَاب لَا تَقُومُ السَّاعَةُ حَتَّى يَمُرَّ الرَّجُلُ بِقَبْرِ الرَّجُلِ فَيَتَمَنَّى أَنْ يَكُونَ مَكَانَ الْمَيِّتِ مِنْ الْبَلَاءِ
Sahih Muslim 157 n

This hadith has been transmitted on the authority of Abu Huraira with a slight variation of wording.

حَدَّثَنَا مُحَمَّدُ بْنُ رَافِعٍ، حَدَّثَنَا عَبْدُ الرَّزَّاقِ، أَخْبَرَنَا مَعْمَرٌ، عَنْ هَمَّامِ بْنِ مُنَبِّهٍ، عَنْ أَبِي هُرَيْرَةَ، عَنِ النَّبِيِّ صلى الله عليه وسلم ‏.‏ بِمِثْلِهِ غَيْرَ أَنَّهُ قَالَ يَنْبَعِثَ ‏.‏
Reference : Sahih Muslim 157n
In-book reference : Book 54, Hadith 107
USC-MSA web (English) reference : Book 41, Hadith 6989
  (deprecated numbering scheme)