The Messenger of Allah ﷺ said, "Fast when you see it and break your fast when you see it. If clouds obscure it from your view, complete the count as thirty, and do not anticipate the month in advance."Hatim said, meaning the count of Shaban.
حدثنا إسماعيل أخبرنا حاتم بن أبي صغيرة عن سماك بن حرب عن عكرمة قال سمعت
قال رسول الله ﷺ صوموا لرؤيته وأفطروا لرؤيته فإن حال بينكم وبينه سحاب فكملوا العدة ثلاثين ولا تستقبلوا الشهر استقبالا قال حاتم يعني عدة شعبان
Its isnad is sahih. Tirmidhi also reported it with the same meaning (2:33) through Abu Ahwas from Simak. Tirmidhi said, "The hadith of Ibn Abbas is a hasan sahih hadith, and it has been reported from him through more than one route." In Muntaqa (2110) it is also attributed to Nasai. See also 1931, 2335, 3022.