The Messenger of Allah ﷺ said, "The month may be twenty-nine days, and it may be thirty. When you see it, begin fasting, and when you see it, break your fast. If it is obscured from you, then complete the count."
أخبرنا أبو داود قال حدثنا هارون قال حدثنا علي هو ابن المبارك قال حدثنا يحيى عن أبي سلمة
قال رسول الله ﷺ الشهر يكون تسعة وعشرين ويكون ثلاثين فإذا رأيتموه فصوموا وإذا رأيتموه فأفطروا فإن غم عليكم فأكملوا العدة
Its isnad is sahih. Tirmidhi narrated it in the book of Fasting, chapter on "Do not anticipate the month by fasting," hadith 684, from the hadith of Abu Salama through this chain. It is also in Al-Kubra, hadith 2448, and Ibn Khuzayma graded it sahih, hadith 1908.Harun is Ibn Ismail Khazzaz Basri, Abu Dawud is Sulayman bin Sayf Harrani, and Yahya is Ibn Abu Kathir.