Abu Hurayrah رضي الله عنه said, "Allah's Messenger ﷺ assigned me to keep watch over the Sadaqah (charity) of Ramadan. A person snuck in and started taking handfuls of foodstuff. I caught him and said, `By Allah, I will take you to Allah's Messenger ﷺ.' He said, `Release me, for I am meek and have many dependents and am in great need.' I released him, and in the morning Allah's Messenger ﷺ asked me, `What did your prisoner do yesterday, O Abu Hurayrah' I said, `O Allah's Messenger ﷺ! He complained of being needy and of having many dependents, so I pitied him and let him go.' Allah's Messenger ﷺ said, `Indeed, he told you a lie and will be coming again.' I believed that he would show up again, for Allah's Messenger ﷺ had told me that he would return. So, I watched for him. When he (showed up and) started stealing handfuls of foodstuff, I caught hold of him again and said, `I will definitely take you to Allah's Messenger ﷺ.' He said, `Leave me, for I am very needy and have many dependents. I promise I will not come back again.' I pitied him and let him go. In the morning Allah's Messenger ﷺ asked me, `What did your prisoner do last night, O Abu Hurayrah!' I replied, `O Allah's Messenger ﷺ! He complained of his great need and of too many dependents, so I took pity on him and set him free.' Allah's Messenger ﷺ said, `Verily, he told you a lie; he will return.'
I waited for him attentively for the third time, and when he (came and) started stealing handfuls of the foodstuff, I caught hold of him and said, `I will surely take you to Allah's Messenger ﷺ as it is the third time you promised not to return, yet you returned.' He said, `Let me teach you some words which Allah will give you benefit from.' I asked, `What are they' He replied, `Whenever you go to bed, recite Ayat Al-Kursi- Allahu la ilaha illa Huwal-Hayyul-Qayyum, till you finish the whole verse. (If you do so), Allah will appoint a guard for you who will stay with you, and no Shaytan will come near you until morning.' So, I released him.
In the morning, Allah's Messenger ﷺ asked, `What did your prisoner do yesterday' I replied, `O Allah's Messenger ﷺ ! He claimed that he would teach me some words by which Allah will grant me some benefit, so I let him go.' Allah's Messenger ﷺ asked, `what are they' I replied, `He said to me: Whenever you go to bed, recite Ayat Al-Kursi from the beginning to the end, Allahu la ilaha illa Huwal-Hayyul-Qayyum. He further said to me: (If you do so), Allah will appoint a guard for you who will stay with you, and no Shaytan will come near you until morning.' (One of the narrators) then commented that they (the Companions) were very keen to do good deeds. The Prophet ﷺ said, `He spoke the truth, although he is a liar. Do you know whom you were talking to, these three nights, O Abu Hurayrah' Abu Hurayrah said, `No.' He said, `It was Shaytan.''' (Sahih Al Bukhari: Vol 6, Book 61, Number 530)