The Prophet ﷺ said, "When one of you comes upon a flock, if its owner is present, let him ask his permission. If permission is granted, let him milk and drink. If no one is with the flock, let him call out three times. If anyone answers, let him ask permission. If no one answers, let him milk and drink, but he must not carry any away."
أن النبي ﷺ قال: إذا أتى أحدكم على ماشية، فإن كان فيها صاحبها فليستأذنه، فإن أذن له فليحتلب وليشرب. وإن لم يكن فيها أحد فليصوت ثلاثا فإن أجابه أحد فليستأذنه، فإن لم يجبه أحد فليحتلب وليشرب، ولا يحمل.
Abu Dawud (2619) and Tirmidhi (1296) both narrated it from the hadith of Abdul-Ala, from Saeed, from Qatada, from Hasan, from Samura bin Jundab. He mentioned it. Tirmidhi said, "The hadith of Samura is a hasan gharib hadith. This is the practice among some of the scholars, and Ahmad and Ishaq hold this view." In some copies it reads, hasan sahih gharib.I say, Hasan's hearing from Samura is sahih, as Ali bin Madini and others have said.