← Sahih al-Bukhari
Sahih al-Bukhari · Hadith #3175 · Beginning of Creation

Narrated Nafi`:

حَدَّثَنَا مَالِكُ بْنُ إِسْمَاعِيلَ، حَدَّثَنَا جَرِيرُ بْنُ حَازِمٍ، عَنْ نَافِعٍ، عَنِ ابْنِ عُمَرَ، أَنَّهُ كَانَ يَقْتُلُ الْحَيَّاتِ‏.‏ فَحَدَّثَهُ أَبُو لُبَابَةَ، أَنَّ النَّبِيَّ صلى الله عليه وسلم نَهَى عَنْ قَتْلِ جِنَّانِ الْبُيُوتِ، فَأَمْسَكَ عَنْهَا‏.‏

Ibn `Umar used to kill snakes but when Abu Lubaba informed him that the Prophet (ﷺ) had forbidden the
killing of snakes living in houses, he gave up killing them.