(53) The Book of Paradise, its Description, its Bounties and its Inhabitants
كتاب الجنة وصفة نعيمها وأهلها
(19) Chapter: The Command To Think Positively Of Allah At The Time Of Death
(19) باب الأَمْرِ بِحُسْنِ الظَّنِّ بِاللَّهِ تَعَالَى عِنْدَ الْمَوْتِ
Sahih Muslim 2878 b 

This hadith has been transmitted on the authority of A'mash but with a slight variation of wording.

حَدَّثَنَا أَبُو بَكْرِ بْنُ نَافِعٍ، حَدَّثَنَا عَبْدُ الرَّحْمَنِ بْنُ مَهْدِيٍّ، عَنْ سُفْيَانَ، عَنِ الأَعْمَشِ، بِهَذَا الإِسْنَادِ ‏.‏ مِثْلَهُ وَقَالَ عَنِ النَّبِيِّ صلى الله عليه وسلم وَلَمْ يَقُلْ سَمِعْتُ ‏.‏
Reference : Sahih Muslim 2878b
In-book reference : Book 53, Hadith 102
USC-MSA web (English) reference : Book 40, Hadith 6879
  (deprecated numbering scheme)