Abu Huraira reported God’s Messenger as saying, "Do not try to go ahead of the imam. 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 sura 1) say ‘Amen’; when he bows bow; and when he says ‘God listens to him who praises Him’ say, ‘O God, our Lord, to Thee be the praise’."
(Bukhari and Muslim, but Bukhari did not mention "and when he says, ‘Nor of those who err”’.)
God’s Messenger led us in prayer one day, and when he finished his prayer he faced us and said, "O people, I am your imam, so do not bow, prostrate yourselves, stand, or go away before I do, for I see you both in front of me and behind me."
Anas said God’s Messenger was thrown off a horse he was riding and his right side was grazed. He then prayed one of the prayers sitting and we prayed behind him sitting, and when he finished he said, "The imam is appointed only to be followed; so when he prays standing pray standing, when he bows bow, when he raises himself raise yourselves, when he says ‘God listens to him who praises Him say, ‘Our Lord, to Thee be the praise’, and when he prays sitting all of you pray sitting."
Al-Humaidi said that "when he prays sitting pray sitting" was said during his earlier illness.* After that the Prophet prayed sitting while the people behind him were standing, but he did not order them to sit, and it is only the last action of the Prophet that is to be acted upon.
* The reference is to his illness at the time when he swore not to go near his wives for a month.
This is Bukhari’s wording, and Muslim has the same up to “all of you”. In a version he added, “Do not act differently from him, and prostrate yourselves when he prostrates himself.”
We used to pray behind the Prophet, and when he said, "God listens to him who praises Him," none of us bowed his back till the Prophet placed his forehead on the ground.