From the Catechism of Trent
Nor let it be supposed that confession, although instituted by our Lord, is not declared by him necessary for the remission of sin: the faithful must be impressed with the conviction, that he who is dead in sin, is to be recalled to spiritual life by means of sacramental confession, a truth clearly conveyed by our Lord himself, when, by a most beautiful metaphor, he calls the power of administering this sacrament, "the keys of the kingdom of heaven." To obtain admittance into any place, the concurrence of him to whom the keys have been committed is necessary, and therefore, as the metaphor implies, to gain admission into heaven, its gates must be opened to us by the power of the keys, confided by Almighty God to the care of his Church. This power should otherwise be nugatory: if heaven can be entered without the power of the keys, in vain shall they to whose fidelity they have been intrusted, assume the prerogative of prohibiting indiscriminate entrance within its portals. This doctrine was familiar to the mind of St. Augustine: "Let no man," says he, "say within himself; I repent in secret with God; God, who has power to pardon me, knows the inmost sentiments of my heart: was there no reason for saying: whatsoever you loose on earth, shall be loosed in heaven; no reason why the keys were given to the Church of God?" The same doctrine is recorded by the pen of St. Ambrose, in his treatise on penance, when refuting the heresy of the Novatians, who asserted that the power of forgiving sins belonged solely to God: "Who," says he, "yields greater reverence to God, he who obeys or he who resists his commands? God commands us to obey his ministers; and by obeying them, we honour God alone."