كتاب المساقاة
22  
The Book of Musaqah
(10)
Chapter: The command to kill dogs, and its abrogation. The prohibition of keeping dogs, except for hunting, farming, (herding) livestock and the like
(10)
بَاب الْأَمْرِ بِقَتْلِ الْكِلَابِ وَبَيَانِ نَسْخِهِ وَبَيَانِ تَحْرِيمِ اقْتِنَائِهَا إِلَّا لِصَيْدٍ أَوْ زَرْعٍ أَوْ مَاشِيَةٍ وَنَحْوِ ذَلِكَ
Sahih Muslim 1573 b

In the hadith transmitted on the authority of Yahya, he (the Holy Prophet) permitted the keeping of dogs for (the protection of) herds, for hunting and (the protection of) cultivated land.

وَحَدَّثَنِيهِ يَحْيَى بْنُ حَبِيبٍ، حَدَّثَنَا خَالِدٌ يَعْنِي ابْنَ الْحَارِثِ، ح وَحَدَّثَنِي مُحَمَّدُ بْنُ، حَاتِمٍ حَدَّثَنَا يَحْيَى بْنُ سَعِيدٍ، ح وَحَدَّثَنِي مُحَمَّدُ بْنُ الْوَلِيدِ، حَدَّثَنَا مُحَمَّدُ بْنُ جَعْفَرٍ، ح وَحَدَّثَنَا إِسْحَاقُ بْنُ إِبْرَاهِيمَ، أَخْبَرَنَا النَّضْرُ، ح وَحَدَّثَنَا مُحَمَّدُ بْنُ الْمُثَنَّى، حَدَّثَنَا وَهْبُ بْنُ جَرِيرٍ، كُلُّهُمْ عَنْ شُعْبَةَ، بِهَذَا الإِسْنَادِ ‏.‏ وَقَالَ ابْنُ حَاتِمٍ فِي حَدِيثِهِ عَنْ يَحْيَى، وَرَخَّصَ، فِي كَلْبِ الْغَنَمِ وَالصَّيْدِ وَالزَّرْعِ ‏.‏
Reference : Sahih Muslim 1573b
In-book reference : Book 22, Hadith 61
USC-MSA web (English) reference : Book 10, Hadith 3814
  (deprecated numbering scheme)