I heard the Messenger of Allah ﷺ say, "Whoever obeys me has obeyed Allah, and whoever disobeys me has disobeyed Allah. Whoever obeys the leader has obeyed me, and whoever disobeys the leader has disobeyed me. The imam is but a shield. If he prays sitting, then pray sitting. When he says, 'Allah hears the one who praises Him,' say, 'O Allah, our Lord, to You be all praise.' For when the words of the people of the earth coincide with the words of the people of the heavens, his past sins are forgiven."
حدثنا محمد بن جعفر قال حدثنا شعبة عن يعلى بن عطاء قال سمعت أبا علقمة يقول سمعت
سمعت رسول الله ﷺ يقول من أطاعني فقد أطاع الله ومن عصاني فقد عصى الله ومن أطاع الأمير فقد أطاعني ومن عصى الأمير فقد عصاني إنما الإمام جنة فإن صلى قاعدا فصلوا قعودا وإذا قال سمع الله لمن حمده فقولوا اللهم ربنا ولك الحمد فإذا وافق قول أهل الأرض قول أهل السماء غفر له ما مضى من ذنبه
Its isnad is sahih. It preceded at 8992, and it is found in two parts in Bukhari 9/77 (Shab edition) and in 6/312, number 3228 (Fath).