The Messenger of Allah ﷺ said, "The imam is appointed only to be followed. When he says the takbir, say the takbir. When he bows, bow. When he says, 'Allah hears whoever praises Him,' say, 'Our Lord, to You belongs all praise.' If he prays standing, pray standing, and if he prays sitting, pray sitting."
حدثنا أبو بكر بن أبي شيبة حدثنا هشيم بن بشير عن عمر بن أبي سلمة عن أبيه
قال رسول الله ﷺ إنما جعل الإمام ليؤتم به فإذا كبر فكبروا وإذا ركع فاركعوا وإذا قال سمع الله لمن حمده فقولوا ربنا ولك الحمد وإن صلى قائما فصلوا قياما وإن صلى قاعدا فصلوا قعودا
Sourcing, sahih. Ibn Abu Shayba narrated it in al-Musannaf, 1/227, no. 2594, from Hushaym, who said, Umar bin Abu Salama told us, transmitting it very briefly. Ahmad narrated it, 2/230, 411, 475, through the hadith of Muhammad bin Amr Laythi from Salama, similar to the version of Ibn Majah. The hadith has many paths of transmission in Bukhari, Muslim, and others.