كتاب الصلاة
4
The Book of Prayers
(7)
Chapter: It Is Recommended For The One Who Hears The Mu'adhdhin To Repeat His Words, Then To Send Salat Upon The Prophet (saws) And Ask Allah To Grant Him Al-Wasilah
(7)
باب اسْتِحْبَابِ الْقَوْلِ مِثْلَ قَوْلِ الْمُؤَذِّنِ لِمَنْ سَمِعَهُ ثُمَّ يُصَلِّي عَلَى النَّبِيِّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ ثُمَّ يَسْأَلُ اللَّهَ لَهُ الْوَسِيلَةَ
Sahih Muslim 386

Sa'd b. Abu Waqqas reported:

The Messenger of Allah (ﷺ) said: If anyone says on hearing the Mu'adhdhin: I testify that there is no god but Allah alone. Who has no partner, and that Muhammad is His servant and His Messenger, (and that) I am satisfied with Allah as my Lord, with Muhammad as Messenger. and with Islam as din (code of life), his sins would be forgiven. In the narration transmitted by Ibn Rumh the words are:" He who said on hearing the Mu'adhdhin and verity I testify." ' Qutaiba has not mentioned his words:" And I."
حَدَّثَنَا مُحَمَّدُ بْنُ رُمْحٍ، أَخْبَرَنَا اللَّيْثُ، عَنِ الْحُكَيْمِ بْنِ عَبْدِ اللَّهِ بْنِ قَيْسٍ الْقُرَشِيِّ، ح وَحَدَّثَنَا قُتَيْبَةُ بْنُ سَعِيدٍ، حَدَّثَنَا لَيْثٌ، عَنِ الْحُكَيْمِ بْنِ عَبْدِ اللَّهِ، عَنْ عَامِرِ بْنِ سَعْدِ بْنِ أَبِي وَقَّاصٍ، عَنْ سَعْدِ بْنِ أَبِي وَقَّاصٍ، عَنْ رَسُولِ اللَّهِ صلى الله عليه وسلم أَنَّهُ قَالَ ‏"‏ مَنْ قَالَ حِينَ يَسْمَعُ الْمُؤَذِّنَ أَشْهَدُ أَنْ لاَ إِلَهَ إِلاَّ اللَّهُ وَحْدَهُ لاَ شَرِيكَ لَهُ وَأَنَّ مُحَمَّدًا عَبْدُهُ وَرَسُولُهُ رَضِيتُ بِاللَّهِ رَبًّا وَبِمُحَمَّدٍ رَسُولاً وَبِالإِسْلاَمِ دِينًا ‏.‏ غُفِرَ لَهُ ذَنْبُهُ ‏"‏ ‏.‏ قَالَ ابْنُ رُمْحٍ فِي رِوَايَتِهِ ‏"‏ مَنْ قَالَ حِينَ يَسْمَعُ الْمُؤَذِّنَ وَأَنَا أَشْهَدُ ‏"‏ ‏.‏ وَلَمْ يَذْكُرْ قُتَيْبَةُ قَوْلَهُ وَأَنَا ‏.‏
Reference : Sahih Muslim 386
In-book reference : Book 4, Hadith 15
USC-MSA web (English) reference : Book 4, Hadith 749
  (deprecated numbering scheme)