Hadithcore
Mishkat al-Masabih, 1138

Abu Huraira reported God’s Messenger as saying, "Do not try to go ahead of the <i>imam</i>. When he says ‘God is most great’ say ‘God is most great’; when he says ‘Nor of those who err’ (i.e. the end of <i>sura</i> 1) say ‘Amen’; when he bows bow; and when he says ‘God listens to him who praises Him’ say, ‘O God, our Lord, to You be the praise’." (Bukhari and Muslim, but Bukhari did not mention "and when he says, ‘Nor of those who err”’.)

وَعَنْ أَبِي هُرَيْرَةَ رَضِيَ اللَّهُ عَنْهُ قَالَ: قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: " لَا تُبَادِرُوا الْإِمَامَ إِذَا كَبَّرَ فكبروا وَإِذا قَالَ: وَلَا الضَّالّين. فَقُولُوا: آمِينَ وَإِذَا رَكَعَ فَارْكَعُوا وَإِذَا قَالَ: سَمِعَ اللَّهُ لِمَنْ حَمِدَهُ فَقُولُوا: اللَّهُمَّ رَبَّنَا لَك الْحَمد " إِلَّا أَنَّ الْبُخَارِيَّ لَمْ يَذْكُرْ: " وَإِذَا قَالَ: وَلَا الضَّالّين "

References1 variant
In-Book Reference
Book 4, Hadith 555