On the authority of Anas ibn Malik – may Allah be pleased with him – he said, “The Messenger of Allah – sallallaahu alayhi wa salam – said:
“Verily, from the people there are those who are keys to what is good and locks to what is bad, and verily, from the people there are those who are keys to what is bad and locks to what is good. So glad tidings to those whom Allah has made the keys to what is good by his hands, and woe to the one whom Allah has made the keys to what is bad by his hands.” [Ibn Majah, Hasan]
Whoever wants for himself that he be from amongst the keys to that which is good, a lock to what is evil, the people of glad tidings, then upon him is what follows:
1. Sincerity for Allah in speech and action. For verily it is the base of all good and source of every virtue.
2. Supplicating to and insisting Allah for success in that. For verily supplication is the key to all good, and Allah does not refuse a slave who supplicates to Him nor does He disappoint a believer who calls Him.
3. Earnest desire for seeking knowledge and acquiring it. For surely knowledge is a cause for virtues and honour, an obstacle for faults and misfortunes.
4. The concern for the worship of Allah and particularly the obligatory actions. Especially the prayer, for surely it prevents from the great and evil sins.
5. The adorning [of oneself] with the noble and highest of manners, and staying far from vulgar and bad manners.
6. Companionship of the good and sitting with the pious. For verily, their sittings are surrounded by the Angels and is covered by the Mercy [of Allah]. And cautioning from sitting with the evil and the wicked for verily it is the dwelling place of the devils.
7. Advising the slaves [of Allah] while in their companionship and association with busying themselves in good and diverting from evil.
8. Remembering the return and standing in front of the Lord of the Universe, for he rewards the good person by his good deeds and the wrongdoer by his wrongdoing.
“So whosoever does good equal to the weight of an atom (or a small ant), shall see it. And whosoever does evil equal to the weight of an atom (or a small ant), shall see it.” [Zalzalah: 8-7]
9. The support of all that [the previous points] is the slave’s desire in good and in benefiting the slaves [of Allah]. So when the desire is upright, the intention resolved, the determination certain, and he seeks help from Allah in that and comes to the affairs through their proper doors, he would be–by Allah’s permission–from the keys to good and the locks to evil.