The Messenger of Allah ﷺ said, "Do not swear by your fathers, nor by your mothers, nor by rivals set up beside Allah. Swear only by Allah, and swear only when you are speaking the truth."
أخبرنا أبو بكر بن علي قال حدثنا عبيد الله بن معاذ قال حدثنا أبي قال حدثنا عوف عن محمد بن سيرين
قال رسول الله ﷺ لا تحلفوا بآبائكم ولا بأمهاتكم ولا بالأنداد ولا تحلفوا إلا بالله ولا تحلفوا إلا وأنتم صادقون
Its isnad is sahih. Abu Dawud narrated it in "Oaths and Vows," chapter on the dislike of swearing by fathers, hadith 3248, from Ubaydullah bin Muaz, through this route. It is also found in al-Kubra, hadith 4710, and Ibn Hibban graded it sahih, hadith 1176.