All perfect praise be to Allah, the Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad is His slave and Messenger.
The hadeeth which you mentioned, dear brother, is an authentic hadeeth reported by Al-Bukhaari and Muslim. It was narrated by Abu Hurayrah, may Allah be pleased with him, that the Prophet said, “The Imaam is but a shield (protection) behind whom you fight and you protect yourself with, so if he orders by piety and is just, then he receives reward for that, and if he orders by other than that, then it is against him.”
Imaam An-Nawawi said about the interpretation of this hadeeth:
“‘The Imaam is a shield’ means like a barricade, because he prevents the enemy from harming the Muslims, and he prevents the people from wronging each other (or being unjust to each other), and he protects the principles and foundations of Islam. The people fear him and fear his might. ‘Behind whom you fight’, means that you fight the disbelievers, the tyrants, the Khawaarij (a deviant sect), and all the corrupt people with him. ‘You protect yourself with’ means against the evil of the enemy, the corrupt people, and the unjust people.”
Allah knows best.