The Prophet ﷺ said, "When the imam says the takbir, say the takbir. When he bows, bow. When he prostrates, prostrate. And if he prays sitting, then pray sitting."
وبإسناده قال إذا كبر الإمام فكبروا وإذا ركع فاركعوا وإذا سجد فاسجدوا وإن صلى جالسا فصلوا جلوسا
Its isnad is sahih. Bukhari 1/106 narrated something similar in "Prayer, prayer on rooftops and the pulpit," as did Muslim 1/309 no. 414 in "Prayer, the follower following the imam," and Humaydi 501 no. 1189.