The Messenger of Allah ﷺ said, "Whoever keeps a dog will have a qirat deducted from his deeds each day, except for a dog kept for farming or livestock."
حدثنا إسماعيل قال أخبرنا هشام الدستوائي قال حدثنا يحيى بن أبي كثير عن أبي سلمة
قال رسول الله ﷺ من أمسك كلبا فإنه ينقص من عمله كل يوم قيراطا إلا كلب حرث أو ماشية
Its chain of transmission is sahih. Bukhari related it, 3/136, in the chapter on sharecropping, on keeping a dog for farming, and Muslim, 3/1201, no. 1574, in the chapter on irrigation partnerships, on the order to kill dogs, and Nasai, 7/186, nos. 4284 to 4291, in the chapter on hunting, on the permission to keep a dog for livestock.