Anas bin Malik reported,

The Messenger of Allah ﷺ used to launch raids at dawn. He would listen for the call to prayer, and if he heard one, he would hold back, otherwise he would attack. He heard a man say, "Allah is the greatest, Allah is the greatest," and the Messenger of Allah ﷺ said, "Upon the natural way."Then the man said, "I bear witness that there is no god but Allah, I bear witness that there is no god but Allah," and the Messenger of Allah ﷺ said, "You have come out of the Fire."They looked, and found him to be a goat herder.

Azami 10364

Sahih

عن أنس قال

كان رسول الله ﷺ يغير إذا طلع الفجر، وكان يستمع الأذان، فإن سمع أذانا أمسك وإلا أغار، فسمع رجلا يقول: الله أكبر الله أكبر، فقال رسول الله ﷺ: على الفطرة. ثم قال: أشهد أن لا إله إلا الله، أشهد أن لا إله إلا الله، فقال رسول الله ﷺ: خرجت من النار. فنظروا فإذا هو راعي معزى.

الأعظمي 10364صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Virtues of the Companions and reports about them
Chapter
Virtues of individual Companions and their reports
Section
Virtue of the shepherd whom the Prophet ﷺ gave glad tidings that he was saved from the Fire
Numbering
Jami al-Kamil 10364 (2nd edition)
Azami 10364